@Override public void process(Operator operator, List<COSBase> operands) throws IOException { if (operator.getImageData() == null || operator.getImageData().length == 0) { return; } PDImage image = new PDInlineImage(operator.getImageParameters(), operator.getImageData(), context.getResources()); context.drawImage(image); }
@Override public InputStream createInputStream(List<String> stopFilters) throws IOException { List<String> filters = getFilters(); ByteArrayInputStream in = new ByteArrayInputStream(rawData); ByteArrayOutputStream out = new ByteArrayOutputStream(rawData.length); for (int i = 0; filters != null && i < filters.size(); i++) { // TODO handling of abbreviated names belongs here, rather than in other classes out.reset(); if (stopFilters.contains(filters.get(i))) { break; } else { Filter filter = FilterFactory.INSTANCE.getFilter(filters.get(i)); filter.decode(in, out, parameters, i); in = new ByteArrayInputStream(out.toByteArray()); } } return new ByteArrayInputStream(out.toByteArray()); }
@Override public PDColorSpace getColorSpace() throws IOException { COSBase cs = parameters.getDictionaryObject(COSName.CS, COSName.COLORSPACE); if (cs != null) { return createColorSpace(cs); } else if (isStencil()) { // stencil mask color space must be gray, it is often missing return PDDeviceGray.INSTANCE; } else { // an image without a color space is always broken throw new IOException("could not determine inline image color space"); } }
/** * Draw an inline image at the x,y coordinates, with the default size of the image. * * @param inlineImage The inline image to draw. * @param x The x-coordinate to draw the inline image. * @param y The y-coordinate to draw the inline image. * * @throws IOException If there is an error writing to the stream. */ public void drawImage(PDInlineImage inlineImage, float x, float y) throws IOException { drawImage(inlineImage, x, y, inlineImage.getWidth(), inlineImage.getHeight()); }
sb.append(inlineImage.getWidth()); sb.append(inlineImage.getHeight()); sb.append(inlineImage.getColorSpace().getName()); if (inlineImage.getDecode() != null && inlineImage.getDecode().size() > 0) for (COSBase base : inlineImage.getDecode()) if (inlineImage.isStencil()) sb.append(inlineImage.getBitsPerComponent()); writeBytes(inlineImage.getData()); writeLine(); writeOperator("EI");
/** * This will parse a type3 stream and create an image from it. * * @return The image that was created. * * @throws IOException * If there is an error processing the stream. */ public Image createImage() throws IOException { showType3Character(charProc); return image.getImage(); }
sb.append(inlineImage.getWidth()); sb.append(inlineImage.getHeight()); sb.append(inlineImage.getColorSpace().getName()); if (inlineImage.getDecode() != null && inlineImage.getDecode().size() > 0) for (COSBase base : inlineImage.getDecode()) if (inlineImage.isStencil()) sb.append(inlineImage.getBitsPerComponent()); writeBytes(inlineImage.getData()); writeLine(); writeOperator("EI");
/** * Draw an inline image at the x,y coordinates, with the default size of the image. * * @param inlineImage The inline image to draw. * @param x The x-coordinate to draw the inline image. * @param y The y-coordinate to draw the inline image. * * @throws IOException If there is an error writing to the stream. * @deprecated Use {@link #drawImage(PDInlineImage, float, float)} instead. */ @Deprecated public void drawInlineImage(PDInlineImage inlineImage, float x, float y) throws IOException { drawImage(inlineImage, x, y, inlineImage.getWidth(), inlineImage.getHeight()); }
/** * This will parse a type3 stream and create an image from it. * * @return The image that was created. * * @throws IOException * If there is an error processing the stream. */ public Image createImage() throws IOException { showType3Character(charProc); return image.getImage(); }
sb.append(inlineImage.getWidth()); sb.append(inlineImage.getHeight()); sb.append(inlineImage.getColorSpace().getName()); if (inlineImage.getDecode() != null && inlineImage.getDecode().size() > 0) for (COSBase base : inlineImage.getDecode()) if (inlineImage.isStencil()) sb.append(inlineImage.getBitsPerComponent()); writeBytes(inlineImage.getData()); writeLine(); writeOperator("EI");
image = new PDInlineImage(operator.getImageParameters(), operator.getImageData(), getResources());
/** * Draw an inline image at the x,y coordinates, with the default size of the image. * * @param inlineImage The inline image to draw. * @param x The x-coordinate to draw the inline image. * @param y The y-coordinate to draw the inline image. * * @throws IOException If there is an error writing to the stream. */ public void drawImage(PDInlineImage inlineImage, float x, float y) throws IOException { drawImage(inlineImage, x, y, inlineImage.getWidth(), inlineImage.getHeight()); }
List<String> filters = getFilters(); if (filters == null || filters.isEmpty())
@Override public PDColorSpace getColorSpace() throws IOException { COSBase cs = parameters.getDictionaryObject(COSName.CS, COSName.COLORSPACE); if (cs != null) { return createColorSpace(cs); } else if (isStencil()) { // stencil mask color space must be gray, it is often missing return PDDeviceGray.INSTANCE; } else { // an image without a color space is always broken throw new IOException("could not determine inline image color space"); } }
/** * This will parse a type3 stream and create an image from it. * * @return The image that was created. * * @throws IOException * If there is an error processing the stream. */ public Image createImage() throws IOException { showType3Character(charProc); return image.getImage(); }
private List<PDInlineImage> getInlineImage() { try { COSBase parameters = this.arguments.get(0); org.apache.pdfbox.pdmodel.graphics.image.PDInlineImage inlineImage = new org.apache.pdfbox.pdmodel.graphics.image.PDInlineImage( (COSDictionary) parameters, this.imageData, this.resources); List<PDInlineImage> inlineImages = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); inlineImages.add(new PBoxPDInlineImage(inlineImage, this.document, this.flavour)); return Collections.unmodifiableList(inlineImages); } catch (IOException e) { LOGGER.debug(e); } return Collections.emptyList(); }
/** * Draw an inline image at the x,y coordinates, with the default size of the image. * * @param inlineImage The inline image to draw. * @param x The x-coordinate to draw the inline image. * @param y The y-coordinate to draw the inline image. * * @throws IOException If there is an error writing to the stream. */ public void drawImage(PDInlineImage inlineImage, float x, float y) throws IOException { drawImage(inlineImage, x, y, inlineImage.getWidth(), inlineImage.getHeight()); }
private List<CosIIFilter> getFilters() { List<String> filters = ((org.apache.pdfbox.pdmodel.graphics.image.PDInlineImage) this.simplePDObject).getFilters(); List<CosIIFilter> result = new ArrayList<>(); if (filters != null) { for (String filter : filters) { result.add(new PBCosIIFilter(filter)); } } return result; }
@Override public PDColorSpace getColorSpace() throws IOException { COSBase cs = parameters.getDictionaryObject(COSName.CS, COSName.COLORSPACE); if (cs != null) { return createColorSpace(cs); } else if (isStencil()) { // stencil mask color space must be gray, it is often missing return PDDeviceGray.INSTANCE; } else { // an image without a color space is always broken throw new IOException("could not determine inline image color space"); } }
@Override public void process(Operator operator, List<COSBase> operands) throws IOException { if (operator.getImageData() == null || operator.getImageData().length == 0) { return; } PDImage image = new PDInlineImage(operator.getImageParameters(), operator.getImageData(), context.getResources()); context.drawImage(image); }