How To Export SharePoint Task List Data To PDF Using A Templating System
April 26, 2011
A couple of times I had the situation where I needed to export SharePoint list data into a PDF file in a customized way. I wanted to use some kind of template technology to translate SharePoint list data into a PDF file. I was working with a text templating system called DotLiquid before (see also my post How To Implement A Generic Template Engine For SharePoint 2010 Using DotLiquid).
It’s a really simple and easy to use template engine for .NET. Another dependency is the PDF library ABCpdf8. You can download a trail version here. This library is very powerful in creating PDF files, especially in adding HTML content to a PDF document.
At the end of this post you can download a SharePoint 2010 sample solution that shows you how to create a new button called “Export to PDF” for each task list, see screenshot below:
This post is actually not describing all the implementation details. I currently have not the time to do this, but I still want to share this solution with you.
The SharePoint 2010 solution adds a new custom action called PDFCreationAction. This action will add a new ribbon button called “Export to PDF” next to the “Export to Excel” button. The button will be displayed for task lists only.
The command action will link to an ASPX-file called CreatePDF.aspx that is doing the actual work. The SharePoint list ID and will be passed as parameter. The Page_Load method of the web form is executing the template against the list data and then the HTML representation will get added to a PDF document using the ABCpdf8 library.