Search code examples
formsflow.aiformsflow

How to get Custom PDF printed in Formsflow.ai


I have a form submission done in formsflow.ai using the opensource - https://github.com/AOT-Technologies/forms-flow-ai, and I have seen it supports normal pdf printing with the default view. Can we use a custom template to print the pdf instead using the form data? Also Is there any API support within the formsflow.ai framework for custom document printing in PDF format, where I can define and use my own templates to include form data?

Tried a sample pdf download with https://github.com/AOT-Technologies/forms-flow-ai/tree/develop/forms-flow-documents#usage-guidlines but couldnt completly get custom pdf working only normal form download I could achieve correctly. Think I am missing something


Solution

  • Yes, it can be accomplished by generating PDFs using a custom theme.

    The formsflow document API serves the purpose of generating PDFs. The document API accepts the 'template' attribute within the request body. The expected value for the 'template' attribute is a Base64-encoded Jinja template. For additional information on the document API, please refer to the following link

    https://github.com/AOT-Technologies/forms-flow-ai/blob/develop/forms-flow-documents/README.md#usage-guidlines

    To tailor the PDF generation process according to your needs, please follow these steps: Begin with a sample form that you wish to export as a PDF.

    Here is a sample form that we export as a PDF: enter image description here

    • To export specific fields such as Name, EmployeeId, and Department from the form, you'll need to make adjustments to the template as outlined in the provided link

    https://gist.github.com/Raveena-aot/bfd691adafdc837dc8ccd0977a3fb535

    • Encode the template using a base64 encoder of your choice. ( Base64 Encode and Decode - Online)

    • Include the encoded template in the body of the Document API’s POST request. http://localhost:5006/document/form/{formid}/submission/{submissionId}/export/pdf)

    • Don't forget to include the Keycloak token in the authorization header for authentication.

    Sample request body: https://gist.github.com/Raveena-aot/5391c042d053b22c29dc8c773d8d611b enter image description here

    With these steps, you can now effectively customize your PDF generation process. If you have any questions or concerns, please feel free to ask.