/** * Returns the value associated to this key as a Rectangle. If the value isn't a PdfArray of which the * firt four elements are PdfNumbers, null is returned. * * @param key the key of which the associated value needs to be returned * @return PdfArray associated with this key * @see PdfArray#toRectangle() */ public Rectangle getAsRectangle(PdfName key) { PdfArray a = getAsArray(key); return a == null ? null : a.toRectangle(); }
/** * Get the rectangle associated to the provided widget. * * @param widget PdfWidgetAnnotation to extract the rectangle from * @return Rectangle */ protected Rectangle getWidgetRectangle(PdfWidgetAnnotation widget) { return widget.getRectangle().toRectangle(); }
/** * Get the rectangle associated to the provided widget. * * @param widget PdfWidgetAnnotation to extract the rectangle from * @return Rectangle */ protected Rectangle getWidgetRectangle(PdfWidgetAnnotation widget) { return widget.getRectangle().toRectangle(); }
/** * Creates a new Canvas to manipulate a specific {@link PdfFormXObject}. * * @param formXObject the form * @param pdfDocument the document that the resulting content stream will be written to */ public Canvas(PdfFormXObject formXObject, PdfDocument pdfDocument) { this(new PdfCanvas(formXObject, pdfDocument), pdfDocument, formXObject.getBBox().toRectangle()); }
/** * Gets the pattern cell's bounding box. These boundaries shall be used to clip the pattern cell. * * @return pattern cell's bounding box. */ public Rectangle getBBox() { return getPdfObject().getAsArray(PdfName.BBox).toRectangle(); }
/** * Creates a new Canvas to manipulate a specific {@link PdfFormXObject}. * * @param formXObject the form * @param pdfDocument the document that the resulting content stream will be written to */ public Canvas(PdfFormXObject formXObject, PdfDocument pdfDocument) { this(new PdfCanvas(formXObject, pdfDocument), pdfDocument, formXObject.getBBox().toRectangle()); }
/** * According to spec (ISO-32000-1, 12.7.3.3) zero font size should interpretaded as auto size. */ private float normalizeFontSize(float fs, PdfFont localFont, PdfArray bBox, String value) { if (fs == 0) { if (isMultiline()) { //We do not support autosize with multiline. fontSize = DEFAULT_FONT_SIZE; } else { // Save it for Default Appearance. fontSize = 0; fs = approximateFontSizeToFitBBox(localFont, bBox.toRectangle(), value); } } if (fs < MIN_FONT_SIZE) { fs = MIN_FONT_SIZE; } return fs; }
/** * According to spec (ISO-32000-1, 12.7.3.3) zero font size should interpretaded as auto size. */ private float normalizeFontSize(float fs, PdfFont localFont, PdfArray bBox, String value) { if (fs == 0) { if (isMultiline()) { //We do not support autosize with multiline. fontSize = DEFAULT_FONT_SIZE; } else { // Save it for Default Appearance. fontSize = 0; fs = approximateFontSizeToFitBBox(localFont, bBox.toRectangle(), value); } } if (fs < MIN_FONT_SIZE) { fs = MIN_FONT_SIZE; } return fs; }
protected Rectangle getRect(PdfDictionary field) { PdfArray rect = field.getAsArray(PdfName.Rect); if (rect == null) { PdfArray kids = field.getAsArray(PdfName.Kids); if (kids == null) { throw new PdfException(PdfException.WrongFormFieldAddAnnotationToTheField); } rect = ((PdfDictionary) kids.get(0)).getAsArray(PdfName.Rect); } return rect != null ? rect.toRectangle() : null; }
protected Rectangle getRect(PdfDictionary field) { PdfArray rect = field.getAsArray(PdfName.Rect); if (rect == null) { PdfArray kids = field.getAsArray(PdfName.Kids); if (kids == null) { throw new PdfException(PdfException.WrongFormFieldAddAnnotationToTheField); } rect = ((PdfDictionary) kids.get(0)).getAsArray(PdfName.Rect); } return rect != null ? rect.toRectangle() : null; }
/** * Gets the {@link Rectangle} specified by page's CropBox, that defines the visible region of default user space. * When the page is displayed or printed, its contents shall be clipped (cropped) to this rectangle * and then shall be imposed on the output medium in some implementation-defined manner. * * @return the {@link Rectangle} object specified by pages's CropBox, expressed in default user space units. * MediaBox by default. */ public Rectangle getCropBox() { PdfArray cropBox = getPdfObject().getAsArray(PdfName.CropBox); if (cropBox == null) { cropBox = (PdfArray) getInheritedValue(PdfName.CropBox, PdfObject.ARRAY); if (cropBox == null) { return getMediaBox(); } } return cropBox.toRectangle(); }
PdfFormXObject appearance = new PdfFormXObject(new Rectangle(0, 0, bBox.toRectangle().getWidth(), bBox.toRectangle().getHeight())); if (formType.equals(PdfName.Tx)) { drawTextAppearance(bBox.toRectangle(), font, fontSize, value, appearance); drawMultiLineTextAppearance(bBox.toRectangle(), font, fontSize, value, appearance);
PdfFormXObject appearance = new PdfFormXObject(new Rectangle(0, 0, bBox.toRectangle().getWidth(), bBox.toRectangle().getHeight())); if (formType.equals(PdfName.Tx)) { drawTextAppearance(bBox.toRectangle(), font, fontSize, value, appearance); drawMultiLineTextAppearance(bBox.toRectangle(), font, fontSize, value, appearance);
Rectangle rect = bBox.toRectangle(); rect.setWidth(bBox.toRectangle().getHeight()); rect.setHeight(bBox.toRectangle().getWidth()); double translationWidth = calculateTranslationWidthAfterFieldRot(bBox.toRectangle(), degreeToRadians(pageRotation), angle); double translationHeight = calculateTranslationHeightAfterFieldRot(bBox.toRectangle(), degreeToRadians(pageRotation), angle); Rectangle rect = bBox.toRectangle(); rect.setWidth(bBox.toRectangle().getHeight()); rect.setHeight(bBox.toRectangle().getWidth()); AppearanceXObject appearance = new AppearanceXObject(new Rectangle(0, 0, bBox.toRectangle().getWidth(), bBox.toRectangle().getHeight())); appearance.addFontFromDR(localFontName, localFont); appearance.put(PdfName.Matrix, matrix); drawTextAppearance(bBox.toRectangle(), localFont, fontSize, value, appearance); } else { drawMultiLineTextAppearance(bBox.toRectangle(), localFont, fontSize, value, appearance); drawMultiLineTextAppearance(bBox.toRectangle(), localFont, fontSize, value, appearance);
Rectangle rect = bBox.toRectangle(); rect.setWidth(bBox.toRectangle().getHeight()); rect.setHeight(bBox.toRectangle().getWidth()); double translationWidth = calculateTranslationWidthAfterFieldRot(bBox.toRectangle(), degreeToRadians(pageRotation), angle); double translationHeight = calculateTranslationHeightAfterFieldRot(bBox.toRectangle(), degreeToRadians(pageRotation), angle); Rectangle rect = bBox.toRectangle(); rect.setWidth(bBox.toRectangle().getHeight()); rect.setHeight(bBox.toRectangle().getWidth()); AppearanceXObject appearance = new AppearanceXObject(new Rectangle(0, 0, bBox.toRectangle().getWidth(), bBox.toRectangle().getHeight())); appearance.addFontFromDR(localFontName, localFont); appearance.put(PdfName.Matrix, matrix); drawTextAppearance(bBox.toRectangle(), localFont, fontSize, value, appearance); } else { drawMultiLineTextAppearance(bBox.toRectangle(), localFont, fontSize, value, appearance); drawMultiLineTextAppearance(bBox.toRectangle(), localFont, fontSize, value, appearance);