Class PdfInvoiceTemplate

All Implemented Interfaces:

public class PdfInvoiceTemplate extends AbstractJacksonPdfTemplate<InvoiceData>
A template for PDFfer that takes an InvoiceData instance as payload and generates a PDF invoice document from it.
  • Constructor Details

    • PdfInvoiceTemplate

      public PdfInvoiceTemplate()
      Instantiates a new Pdf invoice template.
  • Method Details

    • getPayloadClass

      public Class<InvoiceData> getPayloadClass()
      Description copied from interface: PdfTemplate
      Returns the payload class that this template is able to handle. It takes instances of the class returned by this method and produces PDFs from them.
      the payload class
    • initPayload

      protected InvoiceData initPayload(InvoiceData data)
      Description copied from class: AbstractJacksonPdfTemplate

      Override this method to initialize the template and its parts once a payload has been set. For example, you could configure the JSON mapper or any formatters your template might use based on information in the payload. The method also allows you to completely change the payload if you need to and return a different one to be set into the template.

      This method is called by AbstractJacksonPdfTemplate.setPayload(Object), so there is no need to ever override setPayload itself.

      The default implementation does nothing and then returns the same value it receives.

      initPayload in class AbstractJacksonPdfTemplate<InvoiceData>
      data - the payload that is being set into the template
      the payload to be set into the template (in most cases you will simply return the same value you receive)
    • generate

      public void generate()
      Description copied from interface: PdfTemplate
      Prepares the PDF document. It uses the payload set with PdfTemplate.setPayload(Object) and assumes that the payload has already been checked with PdfTemplate.validate(). The generated PDF document can be accessed with PdfTemplate.getPdfContent() after this method returns.