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: How do I analyze a problem PDF?
Date Wed, 01 Mar 2017 19:01:34 GMT
Am 01.03.2017 um 19:56 schrieb Thad Humphries:
> I know that PDDocument (and COSDocument) has a close() method, but how do I
> reopen PDDocument? I see no open() method. In my merge method (below), if

You have to reload it from a file or a stream.

> the global document is closed here (before inDoc.close() as you suggest) or
> elsewhere (in another method), won't the next call to
> "merger.appendDocument(document, inDoc);" fail?

There is no exception for closing a document that uses resources that 
have already been closed. That's why the sequence is important:

First save your work
then close all documents the work is based on.

>    PDDocument document;
>    ...
>    protected void mergePdfDoc(byte [] buffer) throws IOException {
>      PDFMergerUtility merger = new PDFMergerUtility();
>      PDDocument inDoc = PDDocument.load(buffer);
>      merger.appendDocument(document, inDoc);
>      inDoc.close();
>    }
> Is there an exception thrown closing an already closed
> PDDocument/COSDocument? Or reopening an opened document?



> As for fonts, all I'm ever using is the PDType1Font fonts, so I think I'm
> okay there.

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

View raw message