return new COSInputStream(input, results);
/** * Creates a new COSInputStream from an encoded input stream. * * @param filters Filters to be applied. * @param parameters Filter parameters. * @param in Encoded input stream. * @param scratchFile Scratch file to use, or null. * @return Decoded stream. * @throws IOException If the stream could not be read. */ static COSInputStream create(List<Filter> filters, COSDictionary parameters, InputStream in, ScratchFile scratchFile) throws IOException { return create(filters, parameters, in, scratchFile, DecodeOptions.DEFAULT); }
/** * Creates an Image XObject with the given stream as its contents and current color spaces. This * constructor is for internal PDFBox use and is not for PDF generation. Users who want to * create images should look at {@link #createFromFileByExtension(File, PDDocument) }. * * @param stream the XObject stream to read * @param resources the current resources * @throws java.io.IOException if there is an error creating the XObject. */ public PDImageXObject(PDStream stream, PDResources resources) throws IOException { super(stream, COSName.IMAGE); this.resources = resources; List<COSName> filters = stream.getFilters(); if (filters != null && !filters.isEmpty() && COSName.JPX_DECODE.equals(filters.get(filters.size()-1))) { try (COSInputStream is = stream.createInputStream()) { DecodeResult decodeResult = is.getDecodeResult(); stream.getCOSObject().addAll(decodeResult.getParameters()); this.colorSpace = decodeResult.getJPXColorSpace(); } } }
public COSInputStream createInputStream(DecodeOptions options) throws IOException { checkClosed(); if (isWriting) { throw new IllegalStateException("Cannot read while there is an open stream writer"); } ensureRandomAccessExists(true); InputStream input = new RandomAccessInputStream(randomAccess); return COSInputStream.create(getFilterList(), this, input, scratchFile, options); }
private PDImageXObject(PDStream stream, PDResources resources, COSInputStream input) { super(repair(stream, input), COSName.IMAGE); this.resources = resources; this.colorSpace = input.getDecodeResult().getJPXColorSpace(); }
return new COSInputStream(input, results);
/** * Creates a new COSInputStream from an encoded input stream. * * @param filters Filters to be applied. * @param parameters Filter parameters. * @param in Encoded input stream. * @param scratchFile Scratch file to use, or null. * @return Decoded stream. * @throws IOException If the stream could not be read. */ static COSInputStream create(List<Filter> filters, COSDictionary parameters, InputStream in, ScratchFile scratchFile) throws IOException { return create(filters, parameters, in, scratchFile, DecodeOptions.DEFAULT); }
private static PDStream repair(PDStream stream, COSInputStream input) { stream.getCOSObject().addAll(input.getDecodeResult().getParameters()); return stream; }
return new COSInputStream(input, results);
public COSInputStream createInputStream(DecodeOptions options) throws IOException { checkClosed(); if (isWriting) { throw new IllegalStateException("Cannot read while there is an open stream writer"); } ensureRandomAccessExists(true); InputStream input = new RandomAccessInputStream(randomAccess); return COSInputStream.create(getFilterList(), this, input, scratchFile, options); }
/** * Creates an Image XObject with the given stream as its contents and current color spaces. This * constructor is for internal PDFBox use and is not for PDF generation. Users who want to * create images should look at {@link #createFromFileByExtension(File, PDDocument) }. * * @param stream the XObject stream to read * @param resources the current resources * @throws java.io.IOException if there is an error creating the XObject. */ public PDImageXObject(PDStream stream, PDResources resources) throws IOException { super(stream, COSName.IMAGE); this.resources = resources; List<COSName> filters = stream.getFilters(); if (filters != null && !filters.isEmpty() && COSName.JPX_DECODE.equals(filters.get(filters.size()-1))) { COSInputStream is = null; try { is = stream.createInputStream(); DecodeResult decodeResult = is.getDecodeResult(); stream.getCOSObject().addAll(decodeResult.getParameters()); this.colorSpace = decodeResult.getJPXColorSpace(); } finally { IOUtils.closeQuietly(is); } } }
/** * Returns a new InputStream which reads the decoded stream data. * * @return InputStream containing decoded stream data. * @throws IOException If the stream could not be read. */ public COSInputStream createInputStream() throws IOException { checkClosed(); if (isWriting) { throw new IllegalStateException("Cannot read while there is an open stream writer"); } ensureRandomAccessExists(true); InputStream input = new RandomAccessInputStream(randomAccess); return COSInputStream.create(getFilterList(), this, input, scratchFile); }