@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"); }
private void initFringe(Element element) throws IOException { String fringe = element.getAttribute("fringe"); if (fringe != null && !fringe.isEmpty()) { String[] fringeValues = fringe.split(","); if (fringeValues.length != 4) { throw new IOException("Error: wrong amount of numbers in attribute 'fringe'"); } PDRectangle rect = new PDRectangle(); rect.setLowerLeftX(Float.parseFloat(fringeValues[0])); rect.setLowerLeftY(Float.parseFloat(fringeValues[1])); rect.setUpperRightX(Float.parseFloat(fringeValues[2])); rect.setUpperRightY(Float.parseFloat(fringeValues[3])); setFringe(rect); } }
private void initFringe(Element element) throws IOException { String fringe = element.getAttribute("fringe"); if (fringe != null && !fringe.isEmpty()) { String[] fringeValues = fringe.split(","); if (fringeValues.length != 4) { throw new IOException("Error: wrong amount of numbers in attribute 'fringe'"); } PDRectangle rect = new PDRectangle(); rect.setLowerLeftX(Float.parseFloat(fringeValues[0])); rect.setLowerLeftY(Float.parseFloat(fringeValues[1])); rect.setUpperRightX(Float.parseFloat(fringeValues[2])); rect.setUpperRightY(Float.parseFloat(fringeValues[3])); setFringe(rect); } }
private void initFringe(Element element) throws IOException { String fringe = element.getAttribute("fringe"); if (fringe != null && !fringe.isEmpty()) { String[] fringeValues = fringe.split(","); if (fringeValues.length != 4) { throw new IOException("Error: wrong amount of numbers in attribute 'fringe'"); } PDRectangle rect = new PDRectangle(); rect.setLowerLeftX(Float.parseFloat(fringeValues[0])); rect.setLowerLeftY(Float.parseFloat(fringeValues[1])); rect.setUpperRightX(Float.parseFloat(fringeValues[2])); rect.setUpperRightY(Float.parseFloat(fringeValues[3])); setFringe(rect); } }
private void initFringe(Element element) throws IOException { String fringe = element.getAttribute("fringe"); if (fringe != null && !fringe.isEmpty()) { String[] fringeValues = fringe.split(","); if (fringeValues.length != 4) { throw new IOException("Error: wrong amount of numbers in attribute 'fringe'"); } PDRectangle rect = new PDRectangle(); rect.setLowerLeftX(Float.parseFloat(fringeValues[0])); rect.setLowerLeftY(Float.parseFloat(fringeValues[1])); rect.setUpperRightX(Float.parseFloat(fringeValues[2])); rect.setUpperRightY(Float.parseFloat(fringeValues[3])); setFringe(rect); } }
/** * 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; }
rect.setUpperRightX(Math.max(maxX + ab.width / 2, rect.getUpperRightX())); rect.setUpperRightY(Math.max(maxY + ab.width / 2, rect.getUpperRightY())); annotation.setRectangle(rect);
rect.setUpperRightY(x + width); rect.setLowerLeftX(y); rect.setUpperRightX(y + height); break; case 180: rect.setUpperRightX(pageRect.getWidth() - x); rect.setLowerLeftX(pageRect.getWidth() - x - width); rect.setLowerLeftY(y); rect.setUpperRightY(pageRect.getHeight() - x); rect.setLowerLeftX(pageRect.getWidth() - y - height); rect.setUpperRightX(pageRect.getWidth() - y); break; case 0: default: rect.setLowerLeftX(x); rect.setUpperRightX(x + width); rect.setLowerLeftY(pageRect.getHeight() - y - height); rect.setUpperRightY(pageRect.getHeight() - y);
rect.setUpperRightX(Math.max(maxX + ab.width / 2, rect.getUpperRightX())); rect.setUpperRightY(Math.max(maxY + ab.width / 2, rect.getUpperRightY())); annotation.setRectangle(rect);
@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"); }
rect.setUpperRightX(rect.getUpperRightX() - cropBox.getLowerLeftX()); rect.setUpperRightY(rect.getUpperRightY() - cropBox.getLowerLeftY());
glyphBBox.setUpperRightX(Math.min(fontBBox.getUpperRightX(), glyphBBox.getUpperRightX())); glyphBBox.setUpperRightY(Math.min(fontBBox.getUpperRightY(), glyphBBox.getUpperRightY())); path = glyphBBox.toGeneralPath();
rect.setUpperRightX(Math.max(rect.getUpperRightX(), glyphBBox.getUpperRightX())); rect.setUpperRightY(Math.max(rect.getUpperRightY(), glyphBBox.getUpperRightY()));
rect.setUpperRightX(Math.max(maxX + lineWidth, rect.getUpperRightX())); rect.setUpperRightY(Math.max(maxY + lineWidth, rect.getUpperRightY())); annotation.setRectangle(rect);
private PDRectangle adjustRectAndBBox(PDAnnotationText annotation, float width, float height) { // For /Note (other types have different values): // Adobe takes the left upper bound as anchor, and adjusts the rectangle to 18 x 20. // Observed with files 007071.pdf, 038785.pdf, 038787.pdf, // but not with 047745.pdf p133 and 084374.pdf p48, both have the NoZoom flag. // there the BBox is also set to fixed values, but the rectangle is left untouched. // When no flags are there, Adobe sets /F 24 = NoZoom NoRotate. PDRectangle rect = getRectangle(); PDRectangle bbox; if (!annotation.isNoZoom()) { rect.setUpperRightX(rect.getLowerLeftX() + width); rect.setLowerLeftY(rect.getUpperRightY() - height); annotation.setRectangle(rect); } if (!annotation.getCOSObject().containsKey(COSName.F)) { // We set these flags because Adobe does so, but PDFBox doesn't support them when rendering. annotation.setNoRotate(true); annotation.setNoZoom(true); } bbox = new PDRectangle(width, height); annotation.getNormalAppearanceStream().setBBox(bbox); return bbox; }
rect.setUpperRightX(Math.max(maxX + ab.width / 2, rect.getUpperRightX())); rect.setUpperRightY(Math.max(maxY + ab.width / 2, rect.getUpperRightY())); annotation.setRectangle(rect);
rect.setLowerLeftX(lowerLeftX); rect.setLowerLeftY(lowerLeftY); rect.setUpperRightX(lowerLeftX + formWidth); rect.setUpperRightY(lowerLeftY + formHeight);
rect.setLowerLeftX(header.getXMin() * scaling); rect.setLowerLeftY(header.getYMin() * scaling); rect.setUpperRightX(header.getXMax() * scaling); rect.setUpperRightY(header.getYMax() * scaling); fd.setFontBoundingBox(rect);