HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › HTML/CSS rendering issues › Convert html source to pdf
- This topic has 12 replies, 2 voices, and was last updated Mar 26, 2014
19:36:08 byPD4ML.
-
AuthorPosts
-
March 26, 2014 at 12:39#26913
Hi!
Before phurcase this product I must know, if it is possible to convert string array to pdf. The string array contains the html source and every string is the array should be in a new page. Thanks in advance!
ViragMarch 26, 2014 at 12:42#29508There is an API method
pd4ml.render(StringReader[] isrs, OutputStream os, URL base)
which is more-less what you need.
Alternatively I would recommend to merge the string array into a single string, delimited by
<pd4ml:page.break>tags, and to pass it to render() method as a StringReader.March 26, 2014 at 12:57#29509I try what you mention, but only one page were generated, maybe because I use the trial library. The other problem is that the generated page is a, A4 landscape but I set the page orientatio as it is mantioned is the cookbook
March 26, 2014 at 13:03#29510A trial library has no such limitations.
probably there are closing
</body>and</html>tags somewhere in the middle of document. The tags implicitly stop further document parsing.March 26, 2014 at 13:12#29511you are right, iremove the close tags and I have the pages.
March 26, 2014 at 13:21#29512But it still landscape I use the cookbook for try:
pd4ml.setPageSize(pd4ml.changePageOrientation(PD4Constants.A4));March 26, 2014 at 13:37#29513Yes, the code
pd4ml.setPageSize(pd4ml.changePageOrientation(PD4Constants.A4));
forces landscape.For portrait use
pd4ml.setPageSize(PD4Constants.A4);Also you may change the orientation for particular pages with a dedicated parameter of
<pd4ml:page.break>March 26, 2014 at 13:38#29514sorry
March 26, 2014 at 13:59#29515Just one last question. We have text in the html source like this:
<font size="6" face="Arial">ŐŐŐŐŐőőőőőááéűúöüópőúéáűí </font>
But in the pdf it is wrong. The size is good, but the font is wrond and of course the encoding also wrong (hungarian).
I try to set :
pd4ml.useTTF("c:/Windows/Fonts", true);in warious format (case sensitive, use java font etc), but nothing helps. Thanks!
March 26, 2014 at 14:04#29516First you would need to index the fonts in /Windows/Fonts (to generate pd4fonts.properties). See https://pd4ml.com/cookbook/pd4ml_pdf_true_type_fonts.htm
A quick solution would be to place fonts.jar (i.e. from https://pd4ml.com/i/easyfonts/fonts.jar ) to WEB-INF/lib of your web app (or to a shared lib of your desktop application) and to refer to it with:
pd4ml.useTTF("java:fonts", true);March 26, 2014 at 18:35#29517Is this generation also work with demo jar?
March 26, 2014 at 19:02#29518Thanks for your patient! I forgot to tell that I want to use this generation for an applet. I ti add the jad to my project and in the builder it seems that it is succesful, the fonts.jar has been signed and added to the lib folder of the applet. But when I try to create a pdf with the applet the fonts are not used. The color the size and every formatting is good but the font is wrong. What shuold be wrong? Thanks in advance!
March 26, 2014 at 19:36#29519Make sure you use PD4ML Pro. PD4ML Std does not support TTF embedding/national scripts.
-
AuthorPosts
The forum ‘HTML/CSS rendering issues’ is closed to new topics and replies.
