HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › HTML/CSS rendering issues › Text on right side is cut away
- This topic has 10 replies, 2 voices, and was last updated Dec 01, 2017
19:47:25 by PD4ML.
-
AuthorPosts
-
November 9, 2017 at 20:30#27173
Hi,
it is a little bit hard. I only want generate A4 paper PDF.I have a
and a div with a lot of lorem ipsum. On the left is all fine, on the right side the text is cut! Only a few chars or maybe only one.
I want exact positioning on the pdf. For example I want put a box with an exact size of 33 mm. For this I set the setHtmlWidth to 2.83*210
2.83 because 1mm = 2.83ptAlso I added margins with setPageInsetsMM results in a cut right side 🙁
setPageSizeMM is with 210 and 297. Also I added to html style body {width:210mm;height:297mm;}All this have no effect of cutting the right side.
What can I do?November 9, 2017 at 20:46#30117If you define HTML/CSS dimensions in physical units, try
pd4ml.protectPhysicalUnitDimensions() API call.November 9, 2017 at 21:34#30118Okay. I think that this helped.
3.78*210 for htmlWidth is correct?
And a complete other question. I am using the ice pdf viewer and this viewer shows me always the wrong margins on the right side. Do you have a suggestion for an goog pdfviewer?
Thank youNovember 9, 2017 at 21:55#30119The way PD4ML scales HTML layout to “paper” media is explained by the link:
http://pd4ml.com/cookbook/pdf_page_formatting.htmPD4ML uses 72dpi to translate screen pixels to physical units, but after the physical dimensions are translated to screen pixels, the entire layout is translated back to physical units (scaled to fit the target media width). The scale factor depends on htmlWidth, target paper format and paper margins.
protectPhysicalUnitDimensions() protect elements, whose sizes given i.e. in mm, from being scaled at the phase.
FYI constants used by PD4ML:
A4 is 595 x 842pt
MM_PER_INCH = 25.4;
POINTS_PER_MM = 2.835;
POINTS_PER_INCH = 72;
PIXELS_PER_POINT = 1.35;
PIXELS_PER_PICA = 12 * PIXELS_PER_POINT;Regarding a viewer: I’ve got no good tool to recommend, but we definitely have to test PD4ML output with ICE PDF to check what is wrong there.
November 30, 2017 at 14:45#30110Hi
I tried a lot to display correct with icePDF. I attached an picture. Could you find anything out?November 30, 2017 at 18:33#30111Is the issue only with icePDF? Does the doc layout appear in Acroread as expected?
November 30, 2017 at 20:04#30112Sorry first thing I have to correct right is the margin 1 cm
In Adobe it looks correct. Also in other viewers.
Here is the file attached.
The issue is not only in icePDF. Also their is a similar issue with open OpenViewerFX.
OpenViewerFX cuts also the header and footer. The first line of the header is gone also the pagenumber in footer.
And the same issue at the right side.December 1, 2017 at 12:24#30113If you open the document in Acroread its content is rendered correctly using Times font.
IcePDF for some reason uses Arial instead (however in doc font info it still refers to Times).As for me it is a bug of IcePDF, or its free version restriction (which does not include a font engine, according to the download page).
I would recommend to generate PDF with TTFs embedded, not relying to built-in viewer fonts.
December 1, 2017 at 12:33#30114Hmm… On my workstation it always uses Arial instead of any (even embedded) font.
December 1, 2017 at 19:42#30115It looks like the complete restriction of icePDF.
I added to the html code downloaded your 32MB big fonts.jar and added pd4ml.useTTF(“java:fonts”, true)
I think this should embbed the required fonts?December 1, 2017 at 19:47#30116Strange!
pd4ml.useTTF(“java:fonts”, true)
pd4ml.setDefaultTTFs(“Times New Roman”, “Arial”, “Courier New”)After adding this, I see (other as in “normal” pdf viewer) another font face but the margin is correct!
Very strange. -
AuthorPosts
The forum ‘HTML/CSS rendering issues’ is closed to new topics and replies.