List of usage examples for org.apache.pdfbox.pdmodel PDDocument getSignatureFields
public List<PDSignatureField> getSignatureFields()
From source file:com.formkiq.core.service.conversion.PdfToPngFormatConverter.java
License:Apache License
/** * Find {@link PDSignatureField} on the Image. * @param doc {@link PDDocument}/* www . j a v a2 s . c o m*/ * @param result {@link ConversionResult} * @return {@link List} of {@link ConversionField} * @throws IOException IOException */ private List<ConversionField> findSigningButtons(final PDDocument doc, final ConversionResult result) throws IOException { List<ConversionField> fields = new ArrayList<>(); List<PDSignatureField> sigs = doc.getSignatureFields(); for (PDSignatureField s : sigs) { PDRectangle rect = PDRectangleUtil.calculateWidget(s.getWidgets()); PDAnnotationWidget widget = s.getWidgets().get(0); PDPage page = widget.getPage(); int pageNumber = doc.getPages().indexOf(page); float imagePageSize = result.getDataheight() / doc.getNumberOfPages(); float x = rect.getLowerLeftX(); float y = (imagePageSize - rect.getUpperRightY()) + (imagePageSize * pageNumber); ConversionField f = new ConversionField(); f.setDocumentfieldname(s.getFullyQualifiedName()); f.setX(x); f.setY(y); f.setHeight(rect.getHeight()); fields.add(f); } return fields; }
From source file:eu.europa.ejusticeportal.dss.controller.action.DownloadSignedPdfTest.java
License:EUPL
/** * Test downloading the pdf// w w w . j a va2 s. co m * * @throws FileNotFoundException * @throws IOException */ @Test public void downloadPdfTest() throws FileNotFoundException, IOException { HttpServletRequest r = getRequest(); ByteArrayOutputStream os = new ByteArrayOutputStream(); HttpServletResponse p = getResponse(os); new DownloadSealedPdf().elaborate(portal, r, p); ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); PDDocument doc = PDDocument.load(is); assertTrue(doc.getSignatureFields().isEmpty()); }