/** * {@inheritDoc} * The returned images are cached via a SoftReference. */ @Override public BufferedImage getImage() throws IOException { return getImage(null, 1); }
/** * Provide the image for stream. The stream must be image XObject. * * @param resources PDResources for the XObject. * @return A BufferedImage. */ public BufferedImage getImage(PDResources resources) { try { PDImageXObject imageXObject; if (isThumb) { imageXObject = PDImageXObject.createThumbnail(stream); } else { imageXObject = new PDImageXObject(new PDStream(stream), resources); } return imageXObject.getImage(); } catch (IOException e) { e.printStackTrace(); } return null; }
private void writeToBuffer(PDImageXObject pdImage, String suffix, OutputStream out) throws IOException { BufferedImage image = pdImage.getImage(); if (image != null) { if ("jpg".equals(suffix)) {
/** * {@inheritDoc} * The returned images are cached via a SoftReference. */ @Override public BufferedImage getImage() throws IOException { return getImage(null, 1); }
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(); }
protected void processImageOperation(List<COSBase> arguments) throws IOException { COSName objectName = (COSName)arguments.get( 0 ); PDXObject xobject = getResources().getXObject( objectName ); if (xobject instanceof PDImageXObject) { PDImageXObject pdfImage = (PDImageXObject) xobject; BufferedImage outputImage = pdfImage.getImage(); outputImage = rotateImage(outputImage); ImageResource imageData = new ImageResource(getTitle(), outputImage); Rectangle2D bounds = calculateImagePosition(pdfImage); float x = (float) bounds.getX(); float y = (float) bounds.getY(); renderImage(x, y, (float) bounds.getWidth(), (float) bounds.getHeight(), imageData); } }
bImageFound = true; String fname = this.imageDestinationPath + "/" + fileName+ "_" + totalImages + ".png"; ImageIO.write(((org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject)o).getImage(), "png", new File(fname)); imgNames.add(fname); totalImages++;
private void writeToBuffer(PDImageXObject pdImage, String suffix, OutputStream out) throws IOException { BufferedImage image = pdImage.getImage(); if (image != null) { if ("jpg".equals(suffix)) {
private void writeToBuffer(PDImageXObject pdImage, String suffix, OutputStream out) throws IOException { BufferedImage image = pdImage.getImage(); if (image != null) { if ("jpg".equals(suffix)) {
private void writeToBuffer(PDImageXObject pdImage, String suffix, OutputStream out) throws IOException { BufferedImage image = pdImage.getImage(); if (image != null) { if ("jpg".equals(suffix)) {