innoveit / play2-pdf

A PDF module for Play Framework 2
MIT License
77 stars 22 forks source link

Fonts rendering fail #25

Closed alexanderozerov closed 7 years ago

alexanderozerov commented 7 years ago

Hello, I have an issue: When I download PDF using Chrome (last version 60) document rendering fails, server immediately returns empty file. But when I use Chrome in private everything works fine, server spend some time and finally returns pdf with data. Here is stack trace:

[ERROR] - from application in application-akka.actor.default-dispatcher-37
Error creating document from template
org.xhtmlrenderer.util.XRRuntimeException: /tmp/tmp_Roboto-Black7459385378730820963.ttf not found as file or resource.
at org.xhtmlrenderer.pdf.ITextFontResolver.addFont(ITextFontResolver.java:218)
at org.xhtmlrenderer.pdf.ITextFontResolver.addFont(ITextFontResolver.java:193)
at org.xhtmlrenderer.pdf.ITextFontResolver.addFont(ITextFontResolver.java:188)
at it.innove.play.pdf.PdfGenerator.toStream(PdfGenerator.java:111)
at it.innove.play.pdf.PdfGenerator.toBytes(PdfGenerator.java:97)
at it.innove.play.pdf.PdfGenerator.toBytes(PdfGenerator.java:92)
at it.innove.play.pdf.PdfGenerator.ok(PdfGenerator.java:72)
marcosinigaglia commented 7 years ago

Hi, I think you have to use addLocalFonts, it seems that the application can't read the temporary folder.

alexanderozerov commented 7 years ago

True, but I have no idea why it works with Crome in private. It also workd with other browsers, f.e. FF and Safary.

marcosinigaglia commented 7 years ago

I think is only a cache problem, the browser has no part in the rendering.

alexanderozerov commented 7 years ago

It seems one fo the machines does not provide access to temporary fonts directory. Do you know where temporary fonts places in linux? In my work pc on windows it is C:\Users\username\AppData\Local\Temp\tmp_Roboto-Black4442054899741841359.ttf

marcosinigaglia commented 7 years ago

Is the system temp folder, so I think is /tmp