- All Implemented Interfaces:
public class PdfInvoiceTemplate extends AbstractJacksonPdfTemplate<InvoiceData>
A template for PDFfer that takes an
InvoiceDatainstance as payload and generates a PDF invoice document from it.
Fields inherited from class org.nekosoft.pdffer.template.AbstractJacksonPdfTemplate
Constructor SummaryConstructorDescriptionInstantiates a new Pdf invoice template.
Method SummaryModifier and TypeMethodDescription
generate()Prepares the PDF document.Returns the payload class that this template is able to handle.
initPayload(InvoiceData data)Override this method to initialize the template and its parts once a payload has been set.
Methods inherited from class org.nekosoft.pdffer.template.AbstractJacksonPdfTemplate
getJsonMapper, getPayload, getPdfContent, setPayload, setPayloadJson, setPayloadMap, toString, validate, validatePayload
PdfInvoiceTemplatepublic PdfInvoiceTemplate()Instantiates a new Pdf invoice template.
getPayloadClasspublic Class<InvoiceData> getPayloadClass()Description copied from interface:
PdfTemplateReturns 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
initPayloadprotected InvoiceData initPayload(InvoiceData data)Description copied from class:
Override this method to initialize the template and its parts once a payload has been set. For example, you could configure the
JSON mapperor 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
The default implementation does nothing and then returns the same value it receives.
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)
generatepublic void generate()Description copied from interface:
PdfTemplatePrepares 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.