List of usage examples for org.apache.pdfbox.cos COSName DECODE_PARMS
COSName DECODE_PARMS
To view the source code for org.apache.pdfbox.cos COSName DECODE_PARMS.
Click Source Link
From source file:org.apache.fop.render.pdf.pdfbox.PDFBoxAdapter.java
License:Apache License
private Object readCOSStream(COSStream originalStream, Object keyBase) throws IOException { InputStream in;/*from www. j av a 2s. c o m*/ Set filter; if (pdfDoc.isEncryptionActive() || (originalStream.containsKey(COSName.DECODE_PARMS) && !originalStream.containsKey(COSName.FILTER))) { in = originalStream.getUnfilteredStream(); filter = FILTER_FILTER; } else { //transfer encoded data (don't reencode) in = originalStream.getFilteredStream(); filter = Collections.EMPTY_SET; } PDFStream stream = new PDFStream(); OutputStream out = stream.getBufferOutputStream(); IOUtils.copyLarge(in, out); transferDict(originalStream, stream, filter); return cacheClonedObject(keyBase, stream); }
From source file:pdfpicmangler.PDPng.java
License:Open Source License
/** * Construct from a stream./*from w w w.jav a 2s . c o m*/ * * @param doc The document to create the image as part of. * @param is The stream that contains the png data. * @throws IOException If there is an error reading the png data. */ public PDPng(PDDocument doc, InputStream is) throws IOException { super(doc, "png"); System.out.println("reading in png"); COSDictionary dic = getCOSStream(); dic.setItem(COSName.SUBTYPE, COSName.IMAGE); //dic.setItem(COSName.TYPE, COSName.XOBJECT); data = getCOSStream().createFilteredStream(); readPng(is); setWidth(imageWidth); setHeight(imageHeight); dic.setInt(COSName.BITS_PER_COMPONENT, bitDepth); if ((colorType & PNG_TYPE_PALETTE) != 0) { getCOSStream().setItem(COSName.COLORSPACE, paldata); } else if ((colorType & PNG_TYPE_COLOR) != 0) { setColorSpace(PDDeviceRGB.INSTANCE); } else { setColorSpace(new PDDeviceGray()); } COSDictionary filterParams = new COSDictionary(); filterParams.setInt(COSName.PREDICTOR, 15); // png adaptive predictor filterParams.setInt(COSName.COLORS, ((colorType & PNG_TYPE_COLOR) == 0 || (colorType & PNG_TYPE_PALETTE) != 0) ? 1 : 3); filterParams.setInt(COSName.BITS_PER_COMPONENT, bitDepth); filterParams.setInt(COSName.COLUMNS, imageWidth); filterParams.setDirect(true); dic.setItem(COSName.DECODE_PARMS, filterParams); dic.setItem(COSName.FILTER, COSName.FLATE_DECODE); dic.setInt(COSName.LENGTH, dataLen); dic.getDictionaryObject(COSName.LENGTH).setDirect(true); }