[ 
https://issues.apache.org/jira/browse/PDFBOX-3113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15011731#comment-15011731
 ] 

John Hewson edited comment on PDFBOX-3113 at 11/18/15 7:23 PM:
---------------------------------------------------------------

Don't do that. That's for adding a new steam to a PDF.  PDPage#getContents() 
has been replaced with PDPage#getContentStreams() in 2.0 because in 1.8 we lied 
and pretended that a page has a single content stream, however that's not 
necessarily true, it can have an array of content streams. In 1.8 this lie was 
facilitated by COSStreamArray, which violated the PDStream contract in many 
ways, so it was removed in 2.0 and instead we give you access to the multiple 
PDStream objects which can make up a page's contents.

i.e. it's impossible for a page's contents to be a single PDStream. It can be 
list of PDStream, but one PDStream can _not_ represent page content in 2.0, 
because that's how the situation really is in PDF - pages can (and often do) 
have multiple content streams. We provide getContents() which returns an 
InputStream to abstract over this if all you want is to read the concatenated 
data. But if you're after the PDF stream objects (PDStream), we now expose each 
of those directly via getContentStreams(), this makes sense when you think that 
each stream can have its own filters, etc.


was (Author: jahewson):
Don't do that. That's for adding a new steam to a PDF.  PDPage#etContents() has 
been replaced with PDPage#getContentStreams() in 2.0 because in 1.8 we lied and 
pretended that a page has a single content stream, however that's not 
necessarily true, it can have an array of content streams. In 1.8 this lie was 
facilitated by COSStreamArray, which violated the PDStream contract in many 
ways, so it was removed in 2.0 and instead we give you access to the multiple 
PDStream objects which can make up a page's contents.

> Scratch file already closed using PDStream
> ------------------------------------------
>
>                 Key: PDFBOX-3113
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3113
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Parsing
>    Affects Versions: 2.0.0
>            Reporter: simon steiner
>         Attachments: PDFToPDF2.java
>
>
> I get when i try to create a PDStream from a page contents:
> Exception in thread "main" java.io.IOException: Scratch file already closed
>       at org.apache.pdfbox.io.ScratchFile.checkClosed(ScratchFile.java:390
> We used to be able to do:
> PDStream pdStream = page.getContents();



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to