/** * Draw an image at the x,y coordinates, with the default size of the image. * * @param image The image to draw. * @param x The x-coordinate to draw the image. * @param y The y-coordinate to draw the image. * * @throws IOException If there is an error writing to the stream. */ public void drawImage(PDImageXObject image, float x, float y) throws IOException { drawImage(image, x, y, image.getWidth(), image.getHeight()); }
int imageHeight = image.getHeight(); System.out.println("*******************************************************************"); System.out.println("Found image [" + objectName.getName() + "]");
contentStream.drawImage(pdImage, 20, 20, pdImage.getWidth() * scale, pdImage.getHeight() * scale);
/** * Draw an image at the x,y coordinates, with the default size of the image. * * @param image The image to draw. * @param x The x-coordinate to draw the image. * @param y The y-coordinate to draw the image. * * @throws IOException If there is an error writing to the stream. */ public void drawImage(PDImageXObject image, float x, float y) throws IOException { drawImage(image, x, y, image.getWidth(), image.getHeight()); }
private Rectangle2D calculateImagePosition(PDImageXObject pdfImage) throws IOException { Matrix ctm = getGraphicsState().getCurrentTransformationMatrix(); Rectangle2D imageBounds = pdfImage.getImage().getRaster().getBounds(); AffineTransform imageTransform = new AffineTransform(ctm.createAffineTransform()); imageTransform.scale(1.0 / pdfImage.getWidth(), -1.0 / pdfImage.getHeight()); imageTransform.translate(0, -pdfImage.getHeight()); AffineTransform pageTransform = createCurrentPageTransformation(); pageTransform.concatenate(imageTransform); return pageTransform.createTransformedShape(imageBounds).getBounds2D(); }
/** * Draw an image at the x,y coordinates, with the default size of the image. * * @param image The image to draw. * @param x The x-coordinate to draw the image. * @param y The y-coordinate to draw the image. * * @throws IOException If there is an error writing to the stream. */ public void drawImage(PDImageXObject image, float x, float y) throws IOException { drawImage(image, x, y, image.getWidth(), image.getHeight()); }
@Override public void put(COSObject indirect, PDXObject xobject) throws IOException { final int length = xobject.getStream().getLength(); if (length > environment.getMaxImageSize()) { LOG.trace("Not caching image with Size: {}", length); return; } if (xobject instanceof PDImageXObject) { PDImageXObject imageObj = (PDImageXObject) xobject; if (imageObj.getWidth() * imageObj.getHeight() > environment.getMaxImageSize()) { return; } } this.xobjects.put(indirect, new SoftReference<>(xobject)); } }
int imageHeight = image.getHeight(); System.out.println("*******************************************************************"); System.out.println("Found image [" + objectName.getName() + "]");
int imageY = Math.floorDiv((Math.round(rect.getHeight()) - pdxImage.getHeight()), 2);
PDImageXObject pdImageXObject = LosslessFactory.createFromImage(document, bufferedImage); float width = 10 * pdImageXObject.getWidth(); float height = 10 * pdImageXObject.getHeight();
InputStream inputStream = xobject.getStream().getCOSObject().createRawInputStream(); PDImageXObject cloneImage = new PDImageXObject(_writer, inputStream, COSName.FLATE_DECODE, xobject.getWidth(), xobject.getHeight(), xobject.getBitsPerComponent(), xobject.getColorSpace()); cloneImage.setInterpolate(false);
contentStream.drawImage(pdImage, 20, 20, pdImage.getWidth()*scale, pdImage.getHeight()*scale);
InputStream inputStream = xobject.getStream().getCOSObject().createRawInputStream(); PDImageXObject cloneImage = new PDImageXObject(_writer, inputStream, COSName.FLATE_DECODE, xobject.getWidth(), xobject.getHeight(), xobject.getBitsPerComponent(), xobject.getColorSpace()); cloneImage.setInterpolate(false);
InputStream inputStream = xobject.getStream().getCOSObject().createRawInputStream(); PDImageXObject cloneImage = new PDImageXObject(_writer, inputStream, COSName.FLATE_DECODE, xobject.getWidth(), xobject.getHeight(), xobject.getBitsPerComponent(), xobject.getColorSpace()); cloneImage.setInterpolate(false);
InputStream inputStream = xobject.getStream().getCOSObject().createRawInputStream(); PDImageXObject cloneImage = new PDImageXObject(_writer, inputStream, COSName.FLATE_DECODE, xobject.getWidth(), xobject.getHeight(), xobject.getBitsPerComponent(), xobject.getColorSpace()); cloneImage.setInterpolate(false);