Example usage for org.apache.pdfbox.pdmodel PDResources put

List of usage examples for org.apache.pdfbox.pdmodel PDResources put

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel PDResources put.

Prototype

public void put(COSName name, PDXObject xobject) 

Source Link

Document

Sets the XObject resource with the given name.

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);/*  www . jav a  2 s .c o 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();
}