Class PdfferProducerBean

java.lang.Object
org.nekosoft.pdffer.PdfferProducerBean

@Component public class PdfferProducerBean extends Object
The main Spring bean in PDFfer Core. This uses PDF templates - that must be provided by separate libraries - in order to generate PDFs on the fly when needed. It needs an instance of PdfferRegistryBean, that will be used when looking for templates.
  • Constructor Details

    • PdfferProducerBean

      public PdfferProducerBean(PdfferRegistryBean registry)
      Creates a new PdfferProducerBean with the given registry. This is not usually invoked manually. Spring will create an instance of this class and inject the registry.
      Parameters:
      registry - the registry
  • Method Details

    • generatePdfDocumentByPath

      public byte[] generatePdfDocumentByPath(String templatePath, Object data)
      Generates a new PDF with the template at the given template path and with the given payload. The path is split into group and name using PdfTemplate::splitTemplatePath(String).
      Parameters:
      templatePath - the path (group + separator + name ) of the template to be used
      data - the payload needed by the template for PDF generation
      Returns:
      the bytes of the generated PDF document
    • generatePdfDocument

      public byte[] generatePdfDocument(String templateName, Object data)
      Generates a new PDF with the given template (that must be present in the root registry) and the given payload.
      Parameters:
      templateName - the template name (from the root registry)
      data - the payload needed by the template for PDF generation
      Returns:
      the bytes of the generated PDF document
    • generatePdfDocument

      public <T> byte[] generatePdfDocument(String group, String templateName, T data)
      Generates a new PDF with a template by the given name and group and with the given payload.
      Type Parameters:
      T - the type parameter
      Parameters:
      group - the group where the template resides
      templateName - the template name
      data - the payload needed by the template for PDF generation
      Returns:
      the bytes of the generated PDF document
    • generatePdfDocumentByPathFromJsonString

      public byte[] generatePdfDocumentByPathFromJsonString(String templatePath, String data)
      Generates a new PDF with a template at the given path and with the given payload.
      Parameters:
      templatePath - the path (group + separator + name ) of the template to be used
      data - a string containing a JSON representation of the payload for the PDF
      Returns:
      the bytes of the generated PDF document
    • generatePdfDocumentFromJsonString

      public byte[] generatePdfDocumentFromJsonString(String templateName, String data)
      Generates a new PDF with the given template (that must be present in the root registry) and the given payload.
      Parameters:
      templateName - the template name (from the root registry)
      data - a string containing a JSON representation of the payload for the PDF
      Returns:
      the bytes of the generated PDF document
    • generatePdfDocumentFromJsonString

      public byte[] generatePdfDocumentFromJsonString(String group, String templateName, String data)
      Generates a new PDF with a template by the given name and group and with the given payload.
      Parameters:
      group - the group where the template resides
      templateName - the template name
      data - a string containing a JSON representation of the payload for the PDF
      Returns:
      the bytes of the generated PDF document
    • generatePdfDocumentByPathFromJsonMap

      public byte[] generatePdfDocumentByPathFromJsonMap(String templatePath, Map<String,​Object> data)
      Generates a new PDF with the template at the given template path and with the given payload. The path is split into group and name using PdfTemplate::splitTemplatePath(String).
      Parameters:
      templatePath - the path (group + separator + name ) of the template to be used
      data - a java.util.Map representation of the payload for the PDF
      Returns:
      the bytes of the generated PDF document
    • generatePdfDocumentFromJsonMap

      public byte[] generatePdfDocumentFromJsonMap(String templateName, Map<String,​Object> data)
      Generates a new PDF with the given template (that must be present in the root registry) and the given payload.
      Parameters:
      templateName - the template name (from the root registry)
      data - a java.util.Map representation of the payload for the PDF
      Returns:
      the bytes of the generated PDF document
    • generatePdfDocumentFromJsonMap

      public byte[] generatePdfDocumentFromJsonMap(String group, String templateName, Map<String,​Object> data)
      Generates a new PDF with a template by the given name and group and with the given payload.
      Parameters:
      group - the group where the template resides
      templateName - the template name
      data - a java.util.Map representation of the payload for the PDF
      Returns:
      the bytes of the generated PDF document