Create PDF on your website on-the-fly

This eXtension provides a simple but very effective method to generate a PDF document on-the-fly on your website, based on content available in SDL Tridion.

It requires you to download and install Apache FOP: 

  • Open a browser and go to http://xmlgraphics.apache.org/fop 
  • Go to the download page and download the Binary version 
  • Create a folder on the Content Manager server and name it FOP (for instance c:\program files\tridion\fop) 
  • Copy the whole FOP download into that folder     

Attached is an ASPX file you can place on your website. You call this ASPX file with something like www.myweb.com/ftp.aspx?uri=tcm:xx-xxx-xx 

The ASPX page queries the broker for a dynamic component presentation containing the FO for the component. It then creates a PDF file with the name of the URI, and returns the created PDF. 

Attached is a sample Component Template outputting FO. Note that this needs to be a Dynamic Component Presentation. 

Additional notes: 

  • The ASPX page has path variables defined in it. It uses the c:\temp directory for the creation of the PDF. 
  • It then moves the PDF under your website, to the same location where the pdf.aspx file resides. 
  • You might get permission denied errors. Solve this by granting Network Service write access to the folder where the PDF.aspx file is (in order for the page to create the PDF). 
  • Relative Image paths get converted to file system image paths automatically by ASPX.     

For those who want to do more´┐Ż

You can also automatically create FO from HTML using the html2fo option. Extend the c# code in the pdf file to first convert the dynamic component presentation. 

  • Open a browser and go to http://html2fo.sourceforge.net 
  • Locate and click on the official releases link in that page 
  • Download the Win32 version of html2fo 
  • Create a folder on the Content Manager server and name it html2fo (for instance d:\tridion\html2fo) 
  • Copy the html2fo.exe file into that folder    


Developer
Company
:    Amakozi
License agreement
Tags
:    pdf,  content
Version
:   1.0
Source
:   Yes

About the Author
Hendrik Tredoux
CTO & CMO

Hendrik Tredoux worked for SDL Tridion in Amsterdam for seven years prior to co-founding Amakozi Technologies, and was instrumental in the development of the original SDL Tridion WCM product.

Amakozi Technologies

Most Popular Building Blocks

These are the most popular Building Blocks. Did you already get them?