Example usage for org.apache.pdfbox.pdmodel.interactive.annotation PDAnnotationWidget getPage

List of usage examples for org.apache.pdfbox.pdmodel.interactive.annotation PDAnnotationWidget getPage

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel.interactive.annotation PDAnnotationWidget getPage.

Prototype

public PDPage getPage() 

Source Link

Document

This will retrieve the corresponding page of this annotation.

Usage

From source file:com.formkiq.core.service.conversion.PdfToPngFormatConverter.java

License:Apache License

/**
 * Find {@link PDSignatureField} on the Image.
 * @param doc {@link PDDocument}/*from   ww  w. ja  va  2 s.c om*/
 * @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;
}