PDF Transformation

Last modified by Eva Torken on 2023/12/07 14:56

In most cases, you will transform XML messages to other XML messages, or you will transform JSON or EDI messages in another of these formats. However, sometimes you want to create a PDF document as output when transforming your XML data. Just as with the transformations for JSON and EDI, eMagiz also has support objects available that can be used to convert an XML message to a PDF in a similar manner as you are used to for JSON and EDI messages. In this microlearning, we will learn how to configure this solution within the platform.

Should you have any questions, please get in touch with academy@emagiz.com.

1. Prerequisites

  • Expert knowledge of the eMagiz platform

2. Key concepts

This microlearning focuses on creating PDF documents with the help of the transformation functionality in eMagiz.

  • Custom XSLT is needed
  • Support Objects are needed to make the transformation work

3. PDF Transformation

In most cases, you will transform XML messages to other XML messages, or you will transform JSON or EDI messages in another of these formats. However, sometimes you want to create a PDF document as output when transforming your XML data. Just as with the transformations for JSON and EDI, eMagiz also has support objects available that can be used to convert an XML message to a PDF in a similar manner as you are used to for JSON and EDI messages. In this microlearning, we will learn how to configure this solution within the platform.

In contrast to when you transform from XML to JSON or EDI to XML, you cannot use the visual transformation tooling when transforming from your data model message (i.e., XML or JSON) to PDF. This is because the needed PDF structure cannot be visualized via the tooling. However, transforming from XML to PDF works similarly in Create as you are used to transforming from and to JSON and EDI.

So in effect, we need the following to achieve our goal of creating a PDF document via eMagiz:

  • Custom XSLT is needed
  • Support Objects are needed to make the transformation work

In this microlearning, we will focus on configuring the flow correctly and not on learning how to write a custom XSLT that will transform your message into a valid PDF structure. If you want more information on that, please check out XSL-FO.

When turning to the Create phase of eMagiz, we need to open the flow and enter "Start Editing" mode to add the support objects we need. For example, in the left panel of the flow designer, you can search for the term "FOP." This will yield the following results.

expert-create-your-transformations-pdf-transformation-support-objects.png

To transform towards PDF, you must add both support objects to your flow. First, let us start with the "FOP XSL-FO result factory." After dragging it onto the canvas, you need to give it a name and save the support object by double clicking on it without making any changes. The same applies to the second component called "FOP XSL-FO result transformer."

After you have added both support objects to the flow, the last step is to link the support objects to your transformation component in the flow. This can be done on the advanced tab of the XSLT transformer component.

expert-create-your-transformations-pdf-transformation-link-support-objects.png

Do not forget to implement a functional XSLT to get a desirable result

4. Key takeaways

  • So, in effect we need the following to achieve our goal of creating a PDF document via eMagiz:
    • Custom XSLT is needed
    • Support Objects are needed to make the transformation work
  • Using the tooling to create a PDF document can get very complex, and in almost all cases, other alternatives are preferable to this solution

5. Suggested Additional Readings

If you are interested in this topic and want more information on it, please read the help text provided by eMagiz and read more information on the following links: