pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: PDDocument.load()- File vs. InputStream
Date Mon, 01 May 2017 17:58:42 GMT
What version are you using? Hopefully 2.0.5.

Does your code with "getResourceAsStream" also have the file name (with 
.pdf) in it?

If it happens with 2.0.5, then please upload the file somewhere.

Although IMO your code will perform faster if you keep using files, like 
this:

PDDocument.load(new File(getClass().getResource("path/test.pdf").toURI()));

Tilman

Am 01.05.2017 um 19:52 schrieb Attila Kiss:
> 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
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message