You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Andrei Petru Mura <ma...@gmail.com> on 2015/05/15 13:01:11 UTC

Read PDF file

Hi,

Can anyone provied me an example on how to read attachments from a pdf file?

Here is my code, that thrown NullPointerException:

PDDocument document = new PDDocument();
document.load(new File("/path/to/file.pdf"));
document.getDocumentCatalog().getNames().getEmbeddedFiles();

Can anyone provide me a short example?

Thanks,
Andrei

Re: Read PDF file

Posted by Andrei Petru Mura <ma...@gmail.com>.
That solved my problem. Many thanks!

Andrei Mura

On Fri, May 15, 2015 at 2:37 PM, Tilman Hausherr <TH...@t-online.de>
wrote:

> Am 15.05.2015 um 13:01 schrieb Andrei Petru Mura:
>
>> Hi,
>>
>> Can anyone provied me an example on how to read attachments from a pdf
>> file?
>>
>> Here is my code, that thrown NullPointerException:
>>
>> PDDocument document = new PDDocument();
>> document.load(new File("/path/to/file.pdf"));
>>
>
> use
>
> PDDocument document = PDDocument.load(new File("/path/to/file.pdf"));
>
>
> About the test - please see the ExtractEmbeddedFiles example from the
> source code:
>
>
> https://svn.apache.org/viewvc/pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractEmbeddedFiles.java?view=markup&sortby=date
>
> another example is in the TestSymmetricKeyEncryption.java file, this is a
> unit test.
>
> Tilman
>
>
>  document.getDocumentCatalog().getNames().getEmbeddedFiles();
>>
>> Can anyone provide me a short example?
>>
>> Thanks,
>> Andrei
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: Read PDF file

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 15.05.2015 um 13:01 schrieb Andrei Petru Mura:
> Hi,
>
> Can anyone provied me an example on how to read attachments from a pdf file?
>
> Here is my code, that thrown NullPointerException:
>
> PDDocument document = new PDDocument();
> document.load(new File("/path/to/file.pdf"));

use

PDDocument document = PDDocument.load(new File("/path/to/file.pdf"));


About the test - please see the ExtractEmbeddedFiles example from the 
source code:

https://svn.apache.org/viewvc/pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractEmbeddedFiles.java?view=markup&sortby=date

another example is in the TestSymmetricKeyEncryption.java file, this is 
a unit test.

Tilman


> document.getDocumentCatalog().getNames().getEmbeddedFiles();
>
> Can anyone provide me a short example?
>
> Thanks,
> Andrei
>


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