HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML Forums › Technical questions / Troubleshooting › Text gets clipped in PDF with Embedded TTFs
- This topic has 1 reply, 2 voices, and was last updated Oct 27, 2026
22:15:40 byPD4ML.
-
AuthorPosts
-
June 5, 2026 at 16:58#41003
We have a use-case where the right-side of the text in a table is getting clipped. It appears that PD4ML cannot determine the width of each TTF font character. We have evaluated several thousands TTF fonts that are in the Linux distro (google_noto_sans*.ttf and google_noto_serif*.ttf, to name few), but have not found an acceptable set (normal, bold, italic, bold italic) that can be used. It seems like only a few condensed fonts render correctly, but they are not acceptable for business documents. We have been using PD4ML PRO v3 with embedded TTFs for many years successfully, and only recently found this use-case. We upgraded to v4, hoping it would resolve the issue, but have not had any success.
Also, I understand that OTF files should also work, however we have not been able get them to work. Conversion from OTFs to TTFs is not an option because it likely will violate the open source license.
Attached is an example HTML file.
Attachments:
You must be logged in to view attached files.October 27, 2026 at 22:15#41935Hello,
thank you for the sample. A few observations:
1. The sample does not seem to be a font-metrics problem. It uses font-family: Arial with a table that combines rowspan, colspan and fractional percentage widths (72.4053%, 64.5636%, 57.5132%, 79.3618%). The 4.0.24 release (and 4.1.2) fixed several table layout problems of exactly this kind:
– colspan cells over fixed-width columns no longer overlap or clip their content, because their minimum width is now distributed over the spanned columns
– fractional percentage widths such as 4.0002% are applied exactly instead of being rounded
– rowspan height distribution was correctedPlease try the sample with v4.0.24 (or v4.1.2 if you are on the 4.1 line). If the text is still clipped there, please tell us the exact version you tested, the font directory you used and your PD4ML setup code. With that we can reproduce it.
2. OpenType (.otf) fonts with CFF outlines are supported since v4.0.23fx2. Since v4.0.24 and v4.1.2 they are also embedded as a subset, so the PDFs stay small. Conversion to TTF is not needed. If your OTFs did not work in an earlier 4.x build, please retry with a current one.
3. Font setup, for reference:
PD4ML pd4ml = new PD4ML(); pd4ml.useTTF("/usr/share/fonts/truetype/noto", true); // directory is indexed; true = embed pd4ml.setDefaultTTFs("Noto Sans", "Noto Sans", "Noto Sans Mono");In the CSS, use the font family name that the font itself reports, for example font-family: "Noto Sans". Otherwise the text falls back to the built-in Helvetica, whose widths differ from the embedded font. Also check that regular, bold, italic and bold italic files of that family are all in the indexed directory.
You can also pass a name filter to useTTF() to index only the files you need. That avoids picking up the thousands of other fonts on the system.
Best regards,
PD4ML Support -
AuthorPosts
You must be logged in to reply to this topic.
