Class PdfInvoiceTemplate
java.lang.Object
org.nekosoft.pdffer.template.AbstractJacksonPdfTemplate<InvoiceData>
org.nekosoft.PDFferTemplates.invoice.PdfInvoiceTemplate
- All Implemented Interfaces:
PdfTemplate<InvoiceData>
A template for PDFfer that takes an
InvoiceData
instance as payload and
generates a PDF invoice document from it.-
Field Summary
Fields inherited from class org.nekosoft.pdffer.template.AbstractJacksonPdfTemplate
pdfContent
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
generate()
Prepares the PDF document.Returns the payload class that this template is able to handle.protected InvoiceData
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
-
Constructor Details
-
PdfInvoiceTemplate
public PdfInvoiceTemplate()Instantiates a new Pdf invoice template.
-
-
Method Details
-
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.- Returns:
- the payload class
-
initPayload
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 overridesetPayload
itself.The default implementation does nothing and then returns the same value it receives.
- Overrides:
initPayload
in classAbstractJacksonPdfTemplate<InvoiceData>
- Parameters:
data
- the payload that is being set into the template- Returns:
- 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 withPdfTemplate.setPayload(Object)
and assumes that the payload has already been checked withPdfTemplate.validate()
. The generated PDF document can be accessed withPdfTemplate.getPdfContent()
after this method returns.
-