forked from danfickle/openhtmltopdf
-
Notifications
You must be signed in to change notification settings - Fork 42
Set a wildcard fallback for fonts #136
Copy link
Copy link
Open
Description
I have set up a webservice that converts HTML into PDF. Recently, I faced this error:
ERROR 1 --- [html2pdf] [nio-8080-exec-6] c.h.m.services.html2pdf.MainController : Error creating PDF
com.openhtmltopdf.pdfboxout.fontstore.FontNotFoundException: No font for the following specification has been found: Font specification: families: [Lato] size: 267.0 weight: normal style: normal variant: normal
at com.openhtmltopdf.pdfboxout.PdfBoxFastOutputDevice.setFont(PdfBoxFastOutputDevice.java:388) ~[openhtmltopdf-pdfbox-1.1.31.jar!/:na]
at com.openhtmltopdf.render.AbstractOutputDevice.drawText(AbstractOutputDevice.java:75) ~[openhtmltopdf-core-1.1.31.jar!/:na]
at com.openhtmltopdf.render.InlineText.paint(InlineText.java:171) ~[openhtmltopdf-core-1.1.31.jar!/:na]
at com.openhtmltopdf.render.InlineLayoutBox.paintInline(InlineLayoutBox.java:287) ~[openhtmltopdf-core-1.1.31.jar!/:na]
at com.openhtmltopdf.render.displaylist.DisplayListPainter.paintInlineContent(DisplayListPainter.java:135) ~[openhtmltopdf-core-1.1.31.jar!/:na]
at com.openhtmltopdf.render.displaylist.DisplayListPainter.paint(DisplayListPainter.java:262) ~[openhtmltopdf-core-1.1.31.jar!/:na]
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.paintPageFast(PdfBoxRenderer.java:883) ~[openhtmltopdf-pdfbox-1.1.31.jar!/:na]
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.writePDFFast(PdfBoxRenderer.java:596) ~[openhtmltopdf-pdfbox-1.1.31.jar!/:na]
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPdfFast(PdfBoxRenderer.java:496) ~[openhtmltopdf-pdfbox-1.1.31.jar!/:na]
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPDF(PdfBoxRenderer.java:427) ~[openhtmltopdf-pdfbox-1.1.31.jar!/:na]
at com.openhtmltopdf.pdfboxout.PdfRendererBuilder.run(PdfRendererBuilder.java:44) ~[openhtmltopdf-pdfbox-1.1.31.jar!/:na]
It looks like the HTML/CSS has set a font styling to "Lato". My webservice does not ship this font.
Is there a way to avoid this error and have OpenHTML2PDF fall back to some standard (like sans-serif) in such cases?
Unfortunately, I didn't find a good way to do that. E. g. It seems one can not set a custom FontResolver using the PdfRendererBuilder.
Any help is much appreciated!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels