Example usage for org.apache.pdfbox.pdmodel.interactive.annotation PDAnnotation setPage

List of usage examples for org.apache.pdfbox.pdmodel.interactive.annotation PDAnnotation setPage

Introduction

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

Prototype

public void setPage(PDPage page) 

Source Link

Document

This will set the corresponding page for this annotation.

Usage

From source file:fi.riista.feature.permit.invoice.pdf.PermitHarvestInvoicePdfBuilder.java

private void addFormFieldData() throws IOException {
    textField("iban", model.getInvoiceAccountDetails().getCombinedBankNameAndIbanString());
    textField("bic", model.getInvoiceAccountDetails().getBic().toString());
    textField("saaja", model.getPaymentRecipient());
    textField("maksaja", Joiner.on('\n').join(model.getInvoiceRecipient().formatAsLines()));
    textField("summa", model.getAmountText());
    textField("viitenumero", model.getInvoiceReferenceForHuman());
    textField("lisatiedot", model.getInvoiceAdditionalInfo());

    this.acroForm.setNeedAppearances(false);

    // Fix annotations
    for (PDPage page : this.pdfDocument.getPages()) {
        for (PDAnnotation annot : page.getAnnotations()) {
            annot.setPage(page);
        }//  w w  w . j  av a 2  s.  co m
    }

    // Define font resources names used in PDF template
    final PDResources dr = new PDResources();
    dr.put(COSName.getPDFName("Helv"), PDType1Font.HELVETICA);
    dr.put(COSName.getPDFName("HeBo"), PDType1Font.HELVETICA_BOLD);
    this.acroForm.setDefaultResources(dr);

    // Convert form fields to text
    this.acroForm.flatten();
}