Hello everyone,
I am using PDFBox 2.0.4 and I couldn't find the best way to do it.
I hope you can help me :-)
I have a simple application that accepts PDF files (among other formats),
and I currently pass it along (as argument to methods) as a File. In order
to cleanup my code, I wanted to pass it as an InputStream instead... but I
miss one feature in PDFBox 2.0 detecting if the file is password protected.
I think it was possible using the 1.8 version, as we instantiated the doc and
*then* we'd give it the password.
Sample code:
```
try (PDDocument ignore = PDDocument.load(inFile)) {
return null; // not password protected
} catch (InvalidPasswordException ignore) {
}
```
The issue is that when I try to reuse inFile, it tells me it has been closed.
When wrapping it in a CloseShieldInputStream, the whole file is read... leading
to an unwanted memory consumption and/or a temporary file.
This was not an issue with File-s because I could re-recreate an InputStream
when I needed to.
~> Is there a way to check if a file is password-protected *and* if the given
password is the right one, without PDFBox reading it as a whole?
Thanks,
Maxime
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]