pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Attila Kiss <kiss.attila1...@gmail.com>
Subject PDDocument.load()- File vs. InputStream
Date Mon, 01 May 2017 17:52:23 GMT
Hello everybody,
I have a problem and I could not find any solution.

I have a pdf file and when I load the file with PDDocument.load(new
File("absolute/path/to/pdf/file");
it loads perfectly, I can add some text and then save it. Then I open the
file and the original content shows up and my added content shows up as
well.
But when I try to use
PDDocument.load(getClass().getResourceAsStream("/path/in/resources/dir"));
It throws the following error: FlateFilter: stop reading corrupt stream due
to a DataFormatException. And then I open the pdf file, and only the added
content shows up.
But I should use the getResourceAsStream() method, as I could not tell the
absolute file path now, the user will install the app whatever he/she wants.
Any idea, how and why is this happening? Or any solution?
Thanks,
Attila

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message