ralfstuckert / pdfbox-layout

MIT License
156 stars 74 forks source link

Problems loading font file in Spring Boot #33

Closed corrortiz closed 7 years ago

corrortiz commented 7 years ago

I am using this method to load fonts that are in my resource folder:

PDType0Font obscuraFont = PDType0Font.load( document.getPDDocument(), new File(file.ttf"));

Works fine before creating the jar file, But once created the file jar no longer finds the resources this is because spring boot does not allow to search within the jar class path, For this you have to use a InputStream but I could not make it work.

I'm looking for an implementation of PDType0Font.load that will serve with Streams or another way to load Fonts that is compatible with spring boot in production

ralfstuckert commented 7 years ago

Since this is neither an issue nor something involved with this project, I would prefer that you google for a solution instead of creating an issue here. Anyway, if you google for that, you will find that there is a load signature that supports streams, so you can easily load it from the classpath using Class.getResourceAsStream:

https://pdfbox.apache.org/docs/2.0.2/javadocs/org/apache/pdfbox/pdmodel/font/PDType0Font.html#load(org.apache.pdfbox.pdmodel.PDDocument,%20java.io.InputStream)

corrortiz commented 7 years ago

I see apologies, I incorrectly believed that PDType0Font.load was a class created for the project, thank you very much for the link