/** * process : BI : begin inline image. * * @param operator The operator that is being executed. * @param arguments List * @throws IOException If there is an error displaying the inline image. */ public void process(PDFOperator operator, List arguments) throws IOException { PDFObjectExtractor drawer = (PDFObjectExtractor) context; Graphics2D graphics = drawer.getGraphics(); // begin inline image object ImageParameters params = operator.getImageParameters(); PDInlinedImage image = new PDInlinedImage(); image.setImageParameters(params); image.setImageData(operator.getImageData()); // 7.04.09 added try/catch to allow for mis-reading of images // in Kurier // BufferedImage awtImage = image.createImage(); BufferedImage awtImage = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR); try { awtImage = image.createImage(); } catch (Exception e) { e.printStackTrace(); } Matrix ctm = drawer.getGraphicsState().getCurrentTransformationMatrix(); int width = awtImage.getWidth(); int height = awtImage.getHeight(); AffineTransform at = new AffineTransform( ctm.getValue(0, 0) / width, ctm.getValue(0, 1), ctm.getValue(1, 0), ctm.getValue(1, 1) / height, ctm.getValue(2, 0), ctm.getValue(2, 1)); // at.setToRotation((double)page.getRotation()); // The transformation should be done // 1 - Translation // 2 - Rotation // 3 - Scale or Skew // AffineTransform at = new AffineTransform(); // Translation // at = new AffineTransform(); // at.setToTranslation((double)ctm.getValue(0,0), // (double)ctm.getValue(0,1)); // Rotation // AffineTransform toAdd = new AffineTransform(); // toAdd.setToRotation(1.5705); // toAdd.setToRotation(ctm.getValue(2,0)*(Math.PI/180)); // at.concatenate(toAdd); // Scale / Skew? // toAdd.setToScale(width, height); // at.concatenate(toAdd); // at.setToScale( width, height ); graphics.drawImage(awtImage, at, null); // graphics.drawImage( awtImage,0,0, width,height,null); //// drawer.simpleDrawImage(width, height); }
/** * rg Set color space for non stroking operations. * * @param operator The operator that is being executed. * @param arguments List * @throws IOException If an error occurs while processing the font. */ public void process(PDFOperator operator, List arguments) throws IOException { super.process(operator, arguments); PDFObjectExtractor drawer = (PDFObjectExtractor) context; COSNumber r = (COSNumber) arguments.get(0); COSNumber g = (COSNumber) arguments.get(1); COSNumber b = (COSNumber) arguments.get(2); drawer.setNonStrokingColor(new Color(r.floatValue(), g.floatValue(), b.floatValue())); }
/** * fill and stroke the path. * * @param operator The operator that is being executed. * @param arguments List * @throws IOException If an error occurs while processing the font. */ public void process(PDFOperator operator, List arguments) throws IOException { PDFObjectExtractor drawer = (PDFObjectExtractor) context; drawer.simpleFillPath(); GeneralPath currentPath = (GeneralPath) drawer.getLinePath().clone(); context.processOperator("f", arguments); drawer.setLinePath(currentPath); context.processOperator("S", arguments); }