/** * Transforms the given rectangle using the CTM and then intersects it with the current * clipping area. */ private void clipToRect(PDRectangle rectangle) { if (rectangle != null) { GeneralPath clip = rectangle.transform(getGraphicsState().getCurrentTransformationMatrix()); getGraphicsState().intersectClippingPath(clip); } }
GeneralPath p = r.transform(Matrix.getTranslateInstance(-cropBox.getLowerLeftX(), cropBox.getLowerLeftY())); Shape s = flip.createTransformedShape(p); graphics.setColor(Color.green);
GeneralPath transformedBox = form.getBBox().transform(transform);
private void intersectShadingBBox(PDColor color, Area area) throws IOException { if (color.getColorSpace() instanceof PDPattern) { PDColorSpace colorSpace = color.getColorSpace(); PDAbstractPattern pat = ((PDPattern) colorSpace).getPattern(color); if (pat instanceof PDShadingPattern) { PDShading shading = ((PDShadingPattern) pat).getShading(); PDRectangle bbox = shading.getBBox(); if (bbox != null) { Matrix m = Matrix.concatenate(getInitialMatrix(), pat.getMatrix()); Area bboxArea = new Area(bbox.transform(m)); area.intersect(bboxArea); } } } }
if (bbox != null) area = new Area(bbox.transform(ctm)); area.intersect(getGraphicsState().getCurrentClippingPath());
Rectangle2D bbox = tilingPattern.getBBox().transform(patternMatrix).getBounds2D(); PDRectangle rect = new PDRectangle((float)bbox.getX(), (float)bbox.getY(), (float)bbox.getWidth(), (float)bbox.getHeight());
Rectangle2D transformedBox = bbox.transform(matrix).getBounds2D();
PDDocument document = PDDocument.load(resource); PDPage page = document.getDocumentCatalog().getPages().get(0); PDPageContentStream cs = new PDPageContentStream(document, page, PDPageContentStream.AppendMode.PREPEND, false, false); Matrix matrix = Matrix.getRotateInstance(Math.toRadians(45), 0, 0); cs.transform(matrix); cs.close(); PDRectangle cropBox = page.getCropBox(); Rectangle rectangle = cropBox.transform(matrix).getBounds(); PDRectangle newBox = new PDRectangle((float)rectangle.getX(), (float)rectangle.getY(), (float)rectangle.getWidth(), (float)rectangle.getHeight()); page.setCropBox(newBox); page.setMediaBox(newBox);
/** * Transforms the given rectangle using the CTM and then intersects it with the current * clipping area. */ private void clipToRect(PDRectangle rectangle) { if (rectangle != null) { GeneralPath clip = rectangle.transform(getGraphicsState().getCurrentTransformationMatrix()); getGraphicsState().intersectClippingPath(clip); } }
/** * Transforms the given rectangle using the CTM and then intersects it with the current * clipping area. */ private void clipToRect(PDRectangle rectangle) { if (rectangle != null) { GeneralPath clip = rectangle.transform(getGraphicsState().getCurrentTransformationMatrix()); getGraphicsState().intersectClippingPath(clip); } }
PDDocument document = PDDocument.load(resource); PDPage page = document.getDocumentCatalog().getPages().get(0); PDPageContentStream cs = new PDPageContentStream(document, page, PDPageContentStream.AppendMode.PREPEND, false, false); Matrix matrix = Matrix.getRotateInstance(Math.toRadians(45), 0, 0); PDRectangle cropBox = page.getCropBox(); float tx = (cropBox.getLowerLeftX() + cropBox.getUpperRightX()) / 2; float ty = (cropBox.getLowerLeftY() + cropBox.getUpperRightY()) / 2; Rectangle rectangle = cropBox.transform(matrix).getBounds(); float scale = Math.min(cropBox.getWidth() / (float)rectangle.getWidth(), cropBox.getHeight() / (float)rectangle.getHeight()); cs.transform(Matrix.getTranslateInstance(tx, ty)); cs.transform(matrix); cs.transform(Matrix.getScaleInstance(scale, scale)); cs.transform(Matrix.getTranslateInstance(-tx, -ty)); cs.close();
GeneralPath transformedBox = form.getBBox().transform(transform);
@Override public void shadingFill(COSName shadingName) throws IOException { PDShading shading = getResources().getShading(shadingName); if (shading == null) { LOG.error("shading " + shadingName + " does not exist in resources dictionary"); return; } Matrix ctm = getGraphicsState().getCurrentTransformationMatrix(); Paint paint = shading.toPaint(ctm); paint = applySoftMaskToPaint(paint, getGraphicsState().getSoftMask()); graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite()); graphics.setPaint(paint); graphics.setClip(null); lastClip = null; // get the transformed BBox and intersect with current clipping path // need to do it here and not in shading getRaster() because it may have been rotated PDRectangle bbox = shading.getBBox(); if (bbox != null) { Area bboxArea = new Area(bbox.transform(ctm)); bboxArea.intersect(getGraphicsState().getCurrentClippingPath()); graphics.fill(bboxArea); } else { graphics.fill(getGraphicsState().getCurrentClippingPath()); } }
@Override public void shadingFill(COSName shadingName) throws IOException { PDShading shading = getResources().getShading(shadingName); if (shading == null) { LOG.error("shading " + shadingName + " does not exist in resources dictionary"); return; } Matrix ctm = getGraphicsState().getCurrentTransformationMatrix(); Paint paint = shading.toPaint(ctm); paint = applySoftMaskToPaint(paint, getGraphicsState().getSoftMask()); graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite()); graphics.setPaint(paint); graphics.setClip(null); lastClip = null; // get the transformed BBox and intersect with current clipping path // need to do it here and not in shading getRaster() because it may have been rotated PDRectangle bbox = shading.getBBox(); if (bbox != null) { Area bboxArea = new Area(bbox.transform(ctm)); bboxArea.intersect(getGraphicsState().getCurrentClippingPath()); graphics.fill(bboxArea); } else { graphics.fill(getGraphicsState().getCurrentClippingPath()); } }
private void intersectShadingBBox(PDColor color, Area area) throws IOException { if (color.getColorSpace() instanceof PDPattern) { PDColorSpace colorSpace = color.getColorSpace(); PDAbstractPattern pat = ((PDPattern) colorSpace).getPattern(color); if (pat instanceof PDShadingPattern) { PDShading shading = ((PDShadingPattern) pat).getShading(); PDRectangle bbox = shading.getBBox(); if (bbox != null) { Matrix m = Matrix.concatenate(getInitialMatrix(), pat.getMatrix()); Area bboxArea = new Area(bbox.transform(m)); area.intersect(bboxArea); } } } }
private void intersectShadingBBox(PDColor color, Area area) throws IOException { if (color.getColorSpace() instanceof PDPattern) { PDColorSpace colorSpace = color.getColorSpace(); PDAbstractPattern pat = ((PDPattern) colorSpace).getPattern(color); if (pat instanceof PDShadingPattern) { PDShading shading = ((PDShadingPattern) pat).getShading(); PDRectangle bbox = shading.getBBox(); if (bbox != null) { Matrix m = Matrix.concatenate(getInitialMatrix(), pat.getMatrix()); Area bboxArea = new Area(bbox.transform(m)); area.intersect(bboxArea); } } } }
Rectangle2D bbox = tilingPattern.getBBox().transform(patternMatrix).getBounds2D(); PDRectangle rect = new PDRectangle((float)bbox.getX(), (float)bbox.getY(), (float)bbox.getWidth(), (float)bbox.getHeight());
Rectangle2D bbox = tilingPattern.getBBox().transform(patternMatrix).getBounds2D(); PDRectangle rect = new PDRectangle((float)bbox.getX(), (float)bbox.getY(), (float)bbox.getWidth(), (float)bbox.getHeight());
Rectangle2D transformedBox = bbox.transform(matrix).getBounds2D();
Rectangle2D transformedBox = bbox.transform(matrix).getBounds2D();