@Override protected void showFontGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode, Vector displacement) throws IOException { AffineTransform at = textRenderingMatrix.createAffineTransform(); at.concatenate(font.getFontMatrix().createAffineTransform()); // create cache if it does not exist PDVectorFont vectorFont = ((PDVectorFont)font); GlyphCache cache = glyphCaches.get(font); if (cache == null) { cache = new GlyphCache(vectorFont); glyphCaches.put(font, cache); } GeneralPath path = cache.getPathForCharacterCode(code); drawGlyph(path, font, code, displacement, at); }
/** * The cm operator. Concatenates the given matrix with the CTM. * * @param matrix the transformation matrix * @throws IOException If there is an error writing to the stream. */ public void transform(Matrix matrix) throws IOException { if (inTextMode) { throw new IllegalStateException("Error: Modifying the current transformation matrix is not allowed within text objects."); } writeAffineTransform(matrix.createAffineTransform()); writeOperator("cm"); }
/** * The Tm operator. Sets the text matrix to the given values. * A current text matrix will be replaced with the new one. * * @param matrix the transformation matrix * @throws IOException If there is an error writing to the stream. * @throws IllegalStateException If the method was not allowed to be called at this time. */ public void setTextMatrix(Matrix matrix) throws IOException { if (!inTextMode) { throw new IllegalStateException("Error: must call beginText() before setTextMatrix"); } writeAffineTransform(matrix.createAffineTransform()); writeOperator("Tm"); }
/** * Transforms a point using the CTM. */ public Point2D.Float transformedPoint(float x, float y) { float[] position = { x, y }; getGraphicsState().getCurrentTransformationMatrix().createAffineTransform() .transform(position, 0, position, 0, 1); return new Point2D.Float(position[0], position[1]); }
/** * Glyph bounding boxes. */ @Override protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode, Vector displacement) throws IOException { // draw glyph super.showGlyph(textRenderingMatrix, font, code, unicode, displacement); // bbox in EM -> user units Shape bbox = new Rectangle2D.Float(0, 0, font.getWidth(code) / 1000, 1); AffineTransform at = textRenderingMatrix.createAffineTransform(); bbox = at.createTransformedShape(bbox); // save Graphics2D graphics = getGraphics(); Color color = graphics.getColor(); Stroke stroke = graphics.getStroke(); Shape clip = graphics.getClip(); // draw graphics.setClip(graphics.getDeviceConfiguration().getBounds()); graphics.setColor(Color.RED); graphics.setStroke(new BasicStroke(.5f)); graphics.draw(bbox); // restore graphics.setStroke(stroke); graphics.setColor(color); graphics.setClip(clip); }
/** * Not called in TexturePaint subclasses, which is why we wrap TexturePaint. */ @Override public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) { AffineTransform xformPattern = (AffineTransform)xform.clone(); // applies the pattern matrix with scaling removed AffineTransform patternNoScale = patternMatrix.createAffineTransform(); patternNoScale.scale(1 / patternMatrix.getScalingFactorX(), 1 / patternMatrix.getScalingFactorY()); xformPattern.concatenate(patternNoScale); return paint.createContext(cm, deviceBounds, userBounds, xformPattern, hints); }
AffineTransform at = textRenderingMatrix.createAffineTransform(); at.concatenate(font.getFontMatrix().createAffineTransform());
rat = shading.getMatrix().createAffineTransform().createInverse(); rat.concatenate(matrix.createAffineTransform().createInverse()); rat.concatenate(xform.createInverse());
private AffineTransform calculateMatrix(PDRectangle bbox, int rotation) { if (rotation == 0) { return new AffineTransform(); } float tx = 0, ty = 0; switch (rotation) { case 90: tx = bbox.getUpperRightY(); break; case 180: tx = bbox.getUpperRightY(); ty = bbox.getUpperRightX(); break; case 270: ty = bbox.getUpperRightX(); break; default: break; } Matrix matrix = Matrix.getRotateInstance(Math.toRadians(rotation), tx, ty); return matrix.createAffineTransform(); }
at.concatenate(text.getTextMatrix().createAffineTransform()); at.concatenate(text.getTextMatrix().createAffineTransform()); at.concatenate(font.getFontMatrix().createAffineTransform());
AffineTransform at = text.getTextMatrix().createAffineTransform(); at.concatenate(font.getFontMatrix().createAffineTransform());
rat = matrix.createAffineTransform().createInverse(); rat.concatenate(xform.createInverse()); shadingToDevice.concatenate(matrix.createAffineTransform());
/** * Draw an image at the origin with the given transformation matrix. * * @param image The image to draw. * @param matrix The transformation matrix to apply to the image. * * @throws IOException If there is an error writing to the stream. * @throws IllegalStateException If the method was called within a text block. */ public void drawImage(PDImageXObject image, Matrix matrix) throws IOException { if (inTextMode) { throw new IllegalStateException("Error: drawImage is not allowed within a text block."); } saveGraphicsState(); AffineTransform transform = matrix.createAffineTransform(); transform(new Matrix(transform)); writeOperand(resources.add(image)); writeOperator("Do"); restoreGraphicsState(); }
rat = matrix.createAffineTransform().createInverse(); rat.concatenate(xform.createInverse()); shadingToDevice.concatenate(matrix.createAffineTransform());
private Shape calculateGlyphBounds(Matrix textRenderingMatrix, PDFont font, int code) throws IOException AffineTransform at = textRenderingMatrix.createAffineTransform(); at.concatenate(font.getFontMatrix().createAffineTransform()); if (font instanceof PDType3Font)
fontMatrixTransform = getFontMatrix().createAffineTransform(); fontMatrixTransform.scale(1000, 1000);
isDamaged = fontIsDamaged; fontMatrixTransform = getFontMatrix().createAffineTransform(); fontMatrixTransform.scale(1000, 1000);
AffineTransform at = matrix.createAffineTransform(); PDRectangle mediaBox = page.getMediaBox(); PDRectangle cropBox = page.getCropBox();
try AffineTransform at = font.getFontMatrix().createAffineTransform(); if (!at.isIdentity())
Matrix matrix = annotation.getNormalAppearanceStream().getMatrix(); matrix.transformPoint(rd, rd); annotation.getNormalAppearanceStream().setMatrix(matrix.createAffineTransform()); PDRectangle rect2 = new PDRectangle(rect.getLowerLeftX() - rd, rect.getLowerLeftY() - rd, rect.getWidth() + 2 * rd, rect.getHeight() + 2 * rd);