@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); } }
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; }
maxY = Math.max(maxY, y); rect.setLowerLeftX(Math.min(minX - ab.width / 2, rect.getLowerLeftX())); rect.setLowerLeftY(Math.min(minY - ab.width / 2, rect.getLowerLeftY())); rect.setUpperRightX(Math.max(maxX + ab.width / 2, rect.getUpperRightX()));
rect.setLowerLeftY(x); 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(y + height); rect.setLowerLeftY(pageRect.getHeight() - x - width); 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);
maxY = Math.max(maxY, y); rect.setLowerLeftX(Math.min(minX - ab.width / 2, rect.getLowerLeftX())); rect.setLowerLeftY(Math.min(minY - ab.width / 2, rect.getLowerLeftY())); rect.setUpperRightX(Math.max(maxX + ab.width / 2, rect.getUpperRightX()));
@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.setLowerLeftX(Math.min(minX - ab.width * 10, rect.getLowerLeftX())); rect.setLowerLeftY(Math.min(minY - ab.width * 10, rect.getLowerLeftY())); rect.setUpperRightX(Math.max(maxX + ab.width * 10, rect.getUpperRightX()));
if (Float.compare(cropBox.getLowerLeftX(), 0) != 0 || Float.compare(cropBox.getLowerLeftY(), 0) != 0) rect.setLowerLeftX(rect.getLowerLeftX() - cropBox.getLowerLeftX()); rect.setLowerLeftY(rect.getLowerLeftY() - cropBox.getLowerLeftY()); rect.setUpperRightX(rect.getUpperRightX() - cropBox.getLowerLeftX());
glyphBBox.setLowerLeftX(Math.max(fontBBox.getLowerLeftX(), glyphBBox.getLowerLeftX())); glyphBBox.setLowerLeftY(Math.max(fontBBox.getLowerLeftY(), glyphBBox.getLowerLeftY())); glyphBBox.setUpperRightX(Math.min(fontBBox.getUpperRightX(), glyphBBox.getUpperRightX()));
rect.setLowerLeftX(Math.min(rect.getLowerLeftX(), glyphBBox.getLowerLeftX())); rect.setLowerLeftY(Math.min(rect.getLowerLeftY(), glyphBBox.getLowerLeftY())); rect.setUpperRightX(Math.max(rect.getUpperRightX(), glyphBBox.getUpperRightX()));
rect.setLowerLeftX(Math.min(minX - ab.width / 2 - maxDelta, rect.getLowerLeftX())); rect.setLowerLeftY(Math.min(minY - ab.width / 2 - maxDelta, rect.getLowerLeftY())); rect.setUpperRightX(Math.max(maxX + ab.width + maxDelta, rect.getUpperRightX()));
rect.setLowerLeftX(Math.min(minX - lineWidth, rect.getLowerLeftX())); rect.setLowerLeftY(Math.min(minY - lineWidth, rect.getLowerLeftY())); rect.setUpperRightX(Math.max(maxX + lineWidth, rect.getUpperRightX()));
maxY = Math.max(maxY, y); rect.setLowerLeftX(Math.min(minX - ab.width / 2, rect.getLowerLeftX())); rect.setLowerLeftY(Math.min(minY - ab.width / 2, rect.getLowerLeftY())); rect.setUpperRightX(Math.max(maxX + ab.width / 2, rect.getUpperRightX()));
rect.setLowerLeftX(lowerLeftX); rect.setLowerLeftY(lowerLeftY); rect.setUpperRightX(lowerLeftX + formWidth);
PDRectangle rect = new PDRectangle(); float scaling = 1000f / header.getUnitsPerEm(); rect.setLowerLeftX(header.getXMin() * scaling); rect.setLowerLeftY(header.getYMin() * scaling); rect.setUpperRightX(header.getXMax() * scaling);