[
https://issues.apache.org/jira/browse/PDFBOX-3384?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15333103#comment-15333103
]
Tilman Hausherr commented on PDFBOX-3384:
-----------------------------------------
Could you try the same with a small non-spring program and attach it and use a
font that can be downloaded?
> PdfBox-Problem loading ttf file from InputStream.
> -------------------------------------------------
>
> Key: PDFBOX-3384
> URL: https://issues.apache.org/jira/browse/PDFBOX-3384
> Project: PDFBox
> Issue Type: Bug
> Components: FontBox
> Affects Versions: 2.0.0
> Environment: Java 8 - Spring Boot
> Reporter: Fabio
>
> Hallo,
> in my project(a java microservice app with Spring Boot), i've to build from
> scratch a pdf file and want to embed font inside pdf file, for portability
> purpose. I use the follow class of PdfBox framework:
> PDTrueTypeFont
> and the follow method:
> public static PDTrueTypeFont.load(PDDocument doc, InputStream input, Encoding
> encoding) throws IOException
> Because, .ttf files are inside my resources folder inside jar file. I load
> .ttf files from calsspath, with an helper class and method from Spring:
> Resource resource = new ClassPathResource("fonts/file.ttf");
> InputStream resourceInputStream = resource.getInputStream();
> and then, I pass resourceInputStream to PDTrueTypeFont.load with my pdfdoc
> instance and Encoding subclass instance. I receieve always an EOFException
> from load method, I suppose when PdfBox try to read InputStream object. I
> verify that InputStream instance is full and loaded and, if I try to load
> .ttf with the follow method:
> public static PDTrueTypeFont load(PDDocument doc, File file, Encoding
> encoding) throws IOException
> with .ttf file on file system, everything works fine!
> I also try Deprecated method:
> public static PDTrueTypeFont loadTTF(PDDocument doc, InputStream input)
> throws IOException
> But nothing changes.
> My questions now are:
> Is there a problem in my way to pass .ttf to PDTrueTypeFont.load method?
> The InputStream in PDTrueTypeFont.load sign, should be only a
> FileInputStream(pointer to a real file on file system), or can be a
> generic/ByteArrayInputStream from Classpath resources?
> Thank you for your help and sorry for my poor English.
> Best regards.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]