Export PDF (XSLT)

Prev Next

Module Configuration


Locations: 

  • Site Configuration > User Settings > Access Rights;

  • Site Configuration > Module Configuration > Settings.

    In order to be able to use the 'Export PDF (XSLT)' feature  — the following conditions should be adhered to:

  • The corresponding access right ('Export PDF (XSLT)') should be enabled to a module:

    Export_PDF_AccessRights.PNG

    Fig.1.: Export PDF (XSLT) in Access Rights

  • The 'Export PDF (XSLT)' setting should be enabled in the corresponding module Settings:

    Export_PDF_Settings.PNG

    Fig.2.: Export PDF (XSLT) in Module settings

Following these conditions will enable the displaying of the button with the corresponding Label in the Item Information window, so user will be able to download item information in PDF format. If it is necessary to save generated PDF file to other module — please select the Save Exported PDF (XSLT) to Module checkbox and map corresponding Module, File Field and Field Template to be used (as it is shown in the screenshot above)

Templates Configuration and Usage


Location: Site Configuration > Module Configuration > Print Templates

To customize exported PDF xslt is used. First you need to know the xml that will be used. When Export to PDF is configured — in any view navigate to the Item that contains all required fields (from the referencing items either) and download PDF with selected template via Export to PDF.

001_ModuleViewOption.png

Fig.3.: Export PDF option for the Item

003_Modal.PNG

Fig.4.: Export PDF window

Now we have example of xml output as in the example below:

<?xml version="1.0"?>
<printedItem>
	<item id="24" moduleId="115">
		<fields>
			<field id="1078">
				<name>Name Field</name>
				<value>Gold Giraffe</value>
			</field>
			<field id="1248">
				<name>Price </name>
				<value>32.453,00</value>
			</field>
		</fields>
	</item>
	<referringItems>
		<item id="110" moduleId="20">
			<fields>
				<field id="242">
					<name>MediaFile</name>
					<value>Giraffe.png</value>
				</field>
				<field id="1097">
					<name>Size</name>
					<value>Large</value>
				</field>
				<field id="1106">
					<name>Product</name>
					<value id="24">Gold Giraffe</value>
				</field>
			</fields>
		</item>
		<mediaHolders>
			<mediaHolder mediaHolderId="29" moduleId="20">
				<name>MediaFile</name>
				<file fileUrl="/worker/servlets/unsecuredDownloadDelegator?path=...."/>
			</mediaHolder>
			<mediaHolder mediaHolderId="30" moduleId="20">
				<name>PDF Template</name>
			</mediaHolder>
			<mediaHolder mediaHolderId="31" moduleId="20">
				<name>Preview 100</name>
				<file fileUrl="/worker/servlets/unsecuredDownloadDelegator?path...."/>
			</mediaHolder>
		</mediaHolders>
	</referringItems>
</printedItem>

So let's get back to the Site Configuration > Module Settings > Print Templates configuration and create New Template. For example we need all fields and images from the referencing items to be printed. HTML mark-up can be used to make preview look nice, but we will avoid this part. The example below:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml"/>
	<xsl:template match="/">
		<html>
			<head>
				<style>body {font-family: arial;}</style>
			</head>
			<body>
				<table border="1">
					<tr>
						<th>Field name </th>
						<th> Field value</th>
					</tr>
					<xsl:for-each select="printedItem/item/fields/field">
						<tr>
							<td>
								<xsl:value-of select="name"/>
							</td>
							<td>
								<xsl:value-of select="value"/>
							</td>
						</tr>
					</xsl:for-each> 
				</table>
				<img src="{printedItem/referringItems/mediaHolders/mediaHolder[@mediaHolderId='285']/file/@fileUrl}" width="100" hight="100" hspace="1"/>
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>

As you can see from the example above we will get all fields from current item and image from the reference items that is hold in Preview 100 media holder and has id=31. So as the result we will have next PDF:

image350.png

Fig.5.: Result of Exported PDF

To make this PDF look pretty you may use CSS code inside of the