/** * process : W : Set the clipping path using non zero winding rule. * * @param operator The operator that is being executed. * @param arguments List * @throws IOException If there is an error during the processing. */ public void process(PDFOperator operator, List arguments) throws IOException { try { PageDrawer drawer = (PageDrawer) context; drawer.SetClippingPath(GeneralPath.WIND_NON_ZERO); } catch (Exception e) { logger().warning(e.getMessage() + "\n at\n" + FullStackTrace(e)); } }
/** * 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 { PageDrawer drawer = (PageDrawer) context; Graphics2D graphics = drawer.getGraphics(); // begin inline image object ImageParameters params = operator.getImageParameters(); PDInlinedImage image = new PDInlinedImage(); image.setImageParameters(params); image.setImageData(operator.getImageData()); BufferedImage awtImage = image.createImage(); 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); }
/** * process : y : Append curved segment to path (final point replicated). * * @param operator The operator that is being executed. * @param arguments List */ public void process(PDFOperator operator, List<COSBase> arguments) { PageDrawer drawer = (PageDrawer) context; COSNumber x1 = (COSNumber) arguments.get(0); COSNumber y1 = (COSNumber) arguments.get(1); COSNumber x3 = (COSNumber) arguments.get(2); COSNumber y3 = (COSNumber) arguments.get(3); Point2D point1 = drawer.transformedPoint(x1.doubleValue(), y1.doubleValue()); Point2D point3 = drawer.transformedPoint(x3.doubleValue(), y3.doubleValue()); drawer .getLinePath() .curveTo( (float) point1.getX(), (float) point1.getY(), (float) point3.getX(), (float) point3.getY(), (float) point3.getX(), (float) point3.getY()); }