[ https://issues.apache.org/jira/browse/PDFBOX-2274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14109325#comment-14109325 ]
John Hewson commented on PDFBOX-2274: ------------------------------------- Yes, you missed the parameters object in JPXFIlter from result.getParameters(), which sets the BitsPerComponent, ImageMask, Decode, Width, and Height. Repair in PDFBox should not be done to the original COS objects, these should be left intact, so that the file can be saved without modifications. The purpose of DecodeResult is to allow a new dictionary to be returned with the repaired values, which can be used by PDImageXObject, etc. but will not be persisted if the PDF is saved. Currently repair _does_ manipulate the COS object, which probably needs addressing, but it's not the problem here. Generally speaking, doing the following: {code} PDImageXObject image = JPEGFactory.createFromStream(doc, imageStream); InputStream in = image.getStream().getStream().getUnfilteredStream(); {code} Doesn't seem necessary, why would you want to read out the image you just created? > Decoding issue in PDImageXObject > -------------------------------- > > Key: PDFBOX-2274 > URL: https://issues.apache.org/jira/browse/PDFBOX-2274 > Project: PDFBox > Issue Type: Bug > Components: PDModel > Affects Versions: 2.0.0 > Reporter: Dominic Tubach > > I'm using JpegFactory to create an PDImageXObject from a content stream. > There the constrcutor > {code} > PDImageXObject(PDDocument document, InputStream filteredStream, > COSBase cosFilter, int width, int height, int bitsPerComponent, > PDColorSpace initColorSpace) > {code} > is used. > I've found the following issue: > The method getUnfilteredStream() of the COSStream in the PDImageXObject > returns an input stream containing a RandomAccessFileInputStream with > {{currentPosition = 50814}} and {{endPosition = 1440000}} and my following > operation fails. > If the method doDecode() of the COSStream is called before the filter is set > in the COSStream the input stream returned by getUnfilteredStream() contains > a RandomAccessFileInputStream with {{currentPosition = 0}} and {{endPosition > = 50814}} and the result is as expected. > I've achieved this by adding > {code} > getStream().getStream().getDecodeResult(); > {code} > before > {code} > getCOSStream().setItem(COSName.FILTER, cosFilter); > {code} > in the PDImageXObject contructor. -- This message was sent by Atlassian JIRA (v6.2#6252)