You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2016/04/26 22:18:12 UTC
[jira] [Closed] (PDFBOX-3328) "COSStream has been closed and cannot
be read" despite using importPage
[ https://issues.apache.org/jira/browse/PDFBOX-3328?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tilman Hausherr closed PDFBOX-3328.
-----------------------------------
Resolution: Duplicate
> "COSStream has been closed and cannot be read" despite using importPage
> -----------------------------------------------------------------------
>
> Key: PDFBOX-3328
> URL: https://issues.apache.org/jira/browse/PDFBOX-3328
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 2.0.0, 2.0.1, 2.1.0
> Reporter: Tilman Hausherr
>
> By Simon G. on the user mailing list:
> {quote}
> 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:
> {code}
> // 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"));
> {code}
> 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.
> {quote}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org