How to display a document?

I created XSL-FO artifact (in tab Biblioteka → Wydruki) which presents information from form. I would like to display it as PDF to user after sending form. How can I do this?

I. If the data transferred to the document template comes from form fields, the XSL template can be connected to the Document List component. After adding the component on form, configure the “Item” property in the source (“Źródło” tab) - in “documentTemplate” enter the name of the XSL artifact, and in “fileName” the name of the document to be presented on the form; leave the value “fop” for “generatorName”:

<data:DocumentGeneratorItems>
   <data:DocumentGeneratorItem generatorName="fop" fileName="my_file.pdf" documentTemplate="my_template.xsl-*"/>
</data:DocumentGeneratorItems>

II. If the data presented in the PDF document comes from an xml file or we want to save the additionally generated PDF in DMS, then in addition to the Document List component, we must add Document Generator.
The Document List then receives the value from the Document Generator through the property “ Źródło danych z innego pola”:

The Document Generator component cannot be found in the components palette, so you need to add the component configuration in the tab “Źródło”:
a) if the data comes from the xmlDocument variable, the Document Generator must listen on this variable, and the component configuration will be as follows:

<p1:GesDocumentGenerator id="GesDocumentGenerator1" inheritLayout="false">
    <data:ListeningOn>
       <data:ListenField id="xmlDocument"/>
    </data:ListeningOn>
    <data:ClearOn/>
    <p1:GesDocumentGenerator.layoutData>
       <ns6:GridData horizontalAlignment="LEFT" horizontalSpan="6" verticalAlignment="CENTER"/>
    </p1:GesDocumentGenerator.layoutData>
    <data:DocumentGeneratorItems>
       <data:DocumentGeneratorItem generatorName="fopFromVariable" fileName="my_file.pdf" documentTemplate="my_template.xsl-*"/>
    </data:DocumentGeneratorItems>
</p1:GesDocumentGenerator>

b) if the data comes from the form, the Document Generator configuration will be as follows:

<p1:GesDocumentGenerator id="GesDocumentGenerator1" inheritLayout="true">
    <p1:GesDocumentGenerator.layoutData>
       <GridData horizontalAlignment="FILL" horizontalSpan="16"/>
    </p1:GesDocumentGenerator.layoutData>
    <data:DocumentGeneratorItems>
       <data:DocumentGeneratorItem generatorName="fop" fileName="my_file.pdf" documentTemplate="my_temp.xsl-*"/>              
    </data:DocumentGeneratorItems>
</p1:GesDocumentGenerator>

In any case, remember to add XSL templates to the dependencies of the form (tab Właściwości, section Zależności).

1 Like

Thank you for your answer, it’s really helpful! But why I need to add this document template to dependencies? What happen if i don’t do this?

If you don’t add it to the dependency, the template won’t migrate when migrating to another environment.

1 Like

Makes sense, thank you!