Am 26.04.2016 um 20:06 schrieb Tilman Hausherr:
Am 26.04.2016 um 15:59 schrieb Simon Gaeremynck:
Hi,
So far this has happened with any document I’ve tried.
Here’s the latest one: https://s3.amazonaws.com/ally-dev/files/e.pdf
I’m running pdfbox 2.0.1.
Thanks. I have opened https://issues.apache.org/jira/browse/PDFBOX-3328 . You
can also comment there if you're registered (if the lockdown is over).
IMHO the lockdown should be over, at least the banner in JIRA is gone
If you're in a hurry, just copy the source code of PDFCloneUtility and create
your own importPage as described in the issue.
Tilman
The full stack trace:
Exception in thread "main" java.io.IOException: COSStream has been closed and
cannot be read. Perhaps its enclosing PDDocument has been closed?
at org.apache.pdfbox.cos.COSStream.checkClosed(COSStream.java:78)
at org.apache.pdfbox.cos.COSStream.createRawInputStream(COSStream.java:126)
at
org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1177)
at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:372)
at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:158)
at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:561)
at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObjects(COSWriter.java:490)
at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:474)
at
org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1073)
at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:419)
at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1331)
at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1229)
at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1101)
at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1073)
Thanks!
Simon
On 25 Apr 2016, at 23:40, Tilman Hausherr <[email protected]> wrote:
Am 26.04.2016 um 08:08 schrieb Simon Gaeremynck:
Hello,
I’m trying to copy a page from a PDF and adding it to a new (empty) document
but I’m running into an issue when I close the source PDF file before I save
the destination file.
Here’s a code snippet:
// Load up some document from which to copy a page
PDDocument documentA = PDDocument.load(new File("a.pdf"));
// Create a new document and import the first page of the a document
PDDocument newDocument = new PDDocument();
newDocument.importPage(documentA.getPage(0));
// Close the A document as we don't need it any longer
documentA.close();
// Save the new document, this throws:
// COSStream has been closed and cannot be read. Perhaps its enclosing
PDDocument has been closed?
// java.io.IOException: COSStream has been closed and cannot be read.
Perhaps its enclosing PDDocument has been closed?
newDocument.save(new File("new.pdf"));
I get a similar exception when using the PDFMergerUtility class.
I need to copy quite a few pages into a single output document and I’d like
to avoid keeping all those source documents open both at the source and in
the destination document.
Any ideas?
This shouldn't happen when using importPage, as that one should do a deep
copy. Could you upload a PDF somewhere? (Attachments don't work) Please do
also mention what version you are using
Tilman
Kind regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]