/** * Returns the updated <code>Rect</code> entry for the annotation. * The rectangle completely contains the cloudy border. * * @return Annotation <code>Rect</code>. */ PDRectangle getRectangle() { return new PDRectangle((float)bboxMinX, (float)bboxMinY, (float)(bboxMaxX - bboxMinX), (float)(bboxMaxY - bboxMinY)); }
/** * This will get the fonts bounding box from its dictionary. * * @return The fonts bounding box. */ public PDRectangle getFontBBox() { COSBase base = dict.getDictionaryObject(COSName.FONT_BBOX); PDRectangle retval = null; if (base instanceof COSArray) { retval = new PDRectangle((COSArray) base); } return retval; }
/** * This will get the fonts bounding box. * * @return The fonts bounding box. */ public PDRectangle getFontBoundingBox() { COSArray rect = (COSArray)dic.getDictionaryObject( COSName.FONT_BBOX ); PDRectangle retval = null; if( rect != null ) { retval = new PDRectangle( rect ); } return retval; }
/** * The rectangle on the page that this bead is part of. * * @return The part of the page that this bead covers. */ public PDRectangle getRectangle() { PDRectangle rect = null; COSArray array = (COSArray)bead.getDictionaryObject( COSName.R ); if( array != null ) { rect = new PDRectangle( array ); } return rect; }
/** * The rectangle associated with this annotation. * * @return The annotation rectangle. */ public PDRectangle getRectangle() { PDRectangle retval = null; COSArray rectArray = (COSArray) annot.getDictionaryObject(COSName.RECT); if (rectArray != null) { retval = new PDRectangle(rectArray); } return retval; }
private void prepareNonVisibleSignature(PDSignatureField signatureField) { // "Signature fields that are not intended to be visible shall // have an annotation rectangle that has zero height and width." // Set rectangle for non-visual signature to rectangle array [ 0 0 0 0 ] signatureField.getWidgets().get(0).setRectangle(new PDRectangle()); }
@Override public void createPage(PDVisibleSignDesigner properties) { PDPage page = new PDPage(new PDRectangle(properties.getPageWidth(), properties.getPageHeight())); pdfStructure.setPage(page); LOG.info("PDF page has been created"); }
@Override public void createFormatterRectangle(int[] params) { PDRectangle formatterRectangle = new PDRectangle(); formatterRectangle.setLowerLeftX(Math.min(params[0],params[2])); formatterRectangle.setLowerLeftY(Math.min(params[1],params[3])); formatterRectangle.setUpperRightX(Math.max(params[0],params[2])); formatterRectangle.setUpperRightY(Math.max(params[1],params[3])); pdfStructure.setFormatterRectangle(formatterRectangle); LOG.info("Formatter rectangle has been created"); }
/** * This will retrieve the rectangle specifying the location of the viewport. * * @return the location */ public PDRectangle getBBox() { COSBase bbox = this.getCOSObject().getDictionaryObject(COSName.BBOX); if (bbox instanceof COSArray) { return new PDRectangle((COSArray) bbox); } return null; }
PDDocument document = new PDDocument(); InputStream in = new FileInputStream(someImage); BufferedImage bimg = ImageIO.read(in); float width = bimg.getWidth(); float height = bimg.getHeight(); PDPage page = new PDPage(new PDRectangle(width, height)); document.addPage(page); PDXObjectImage img = new PDJpeg(document, new FileInputStream(someImage)); PDPageContentStream contentStream = new PDPageContentStream(document, page); contentStream.drawImage(img, 0, 0); contentStream.close(); in.close(); document.save("test.pdf"); document.close();
/** * Gets the bounding box. * * @return the bounding box. */ public PDRectangle getBBox() { COSArray array = (COSArray) this.getCOSObject().getDictionaryObject(BBOX); if (array != null) { return new PDRectangle(array); } return null; }
/** * Gets the artifact's bounding box (BBox). * * @return the artifact's bounding box */ public PDRectangle getBBox() { PDRectangle retval = null; COSArray a = (COSArray) this.getProperties().getDictionaryObject( COSName.BBOX); if (a != null) { retval = new PDRectangle(a); } return retval; }
/** * This will get the rectangle difference rectangle. Giving the difference between the * annotations rectangle and where the drawing occurs. (To take account of any effects applied * through the BE entry for example) * * @return the rectangle difference */ public PDRectangle getRectDifference() { COSBase base = getCOSObject().getDictionaryObject(COSName.RD); if (base instanceof COSArray) { return new PDRectangle((COSArray) base); } return null; }
private void assignSignatureRectangle(PDSignatureField signatureField, COSDictionary annotDict) { // Read and set the rectangle for visual signature COSArray rectArray = (COSArray) annotDict.getDictionaryObject(COSName.RECT); PDRectangle rect = new PDRectangle(rectArray); PDRectangle existingRectangle = signatureField.getWidgets().get(0).getRectangle(); //in case of an existing field keep the original rect if (existingRectangle == null || existingRectangle.getCOSArray().size() != 4) { signatureField.getWidgets().get(0).setRectangle(rect); } }
/** * Get a padded rectangle. * * <p>Creates a new rectangle with padding applied to each side. * . * @param rectangle the rectangle. * @param padding the padding to apply. * @return the padded rectangle. */ PDRectangle getPaddedRectangle(PDRectangle rectangle, float padding) { return new PDRectangle(rectangle.getLowerLeftX() + padding, rectangle.getLowerLeftY() + padding, rectangle.getWidth() - 2 * padding, rectangle.getHeight() - 2 * padding); }
/** * Apply padding to a box. * * @param box box * @return the padded box. */ private PDRectangle applyPadding(PDRectangle box, float padding) { return new PDRectangle(box.getLowerLeftX() + padding, box.getLowerLeftY() + padding, box.getWidth() - 2 * padding, box.getHeight() - 2 * padding); } }
/** * This will create a translated rectangle based off of this rectangle, such * that the new rectangle retains the same dimensions(height/width), but the * lower left x,y values are zero. <br> * 100, 100, 400, 400 (llx, lly, urx, ury ) <br> * will be translated to 0,0,300,300 * * @return A new rectangle that has been translated back to the origin. */ public PDRectangle createRetranslatedRectangle() { PDRectangle retval = new PDRectangle(); retval.setUpperRightX( getWidth() ); retval.setUpperRightY( getHeight() ); return retval; }
private static void changeCropBox(PDDocument document, float a, float b, float c, float d) { for (PDPage page : document.getPages()) { System.out.println("resizing page"); PDRectangle rectangle = new PDRectangle(); rectangle.setLowerLeftX(a); rectangle.setLowerLeftY(b); rectangle.setUpperRightX(c); rectangle.setUpperRightY(d); page.setCropBox(rectangle); } } }
/** * Clips the given box to the bounds of the media box. */ private PDRectangle clipToMediaBox(PDRectangle box) { PDRectangle mediaBox = getMediaBox(); PDRectangle result = new PDRectangle(); result.setLowerLeftX(Math.max(mediaBox.getLowerLeftX(), box.getLowerLeftX())); result.setLowerLeftY(Math.max(mediaBox.getLowerLeftY(), box.getLowerLeftY())); result.setUpperRightX(Math.min(mediaBox.getUpperRightX(), box.getUpperRightX())); result.setUpperRightY(Math.min(mediaBox.getUpperRightY(), box.getUpperRightY())); return result; }
@Override public void createSignatureRectangle(PDSignatureField signatureField, PDVisibleSignDesigner properties) throws IOException { PDRectangle rect = new PDRectangle(); rect.setUpperRightX(properties.getxAxis() + properties.getWidth()); rect.setUpperRightY(properties.getTemplateHeight() - properties.getyAxis()); rect.setLowerLeftY(properties.getTemplateHeight() - properties.getyAxis() - properties.getHeight()); rect.setLowerLeftX(properties.getxAxis()); signatureField.getWidgets().get(0).setRectangle(rect); pdfStructure.setSignatureRectangle(rect); LOG.info("Signature rectangle has been created"); }