Sharepoint List to PDF report

Will picture Will · Aug 11, 2009 · Viewed 18.8k times · Source

I have a SharePoint list and I need to transform it into a document (any type) and export it to PDF. Would you have any tips on the best way to do this? I have Crystal Reports but not sure if this is the correct use case for this.

Answer

Daniel Segan picture Daniel Segan · Aug 12, 2009

You can programatically access the document library using the object model or via web services.

If you use the object model. You can use the SPContext object to get the current site/list. From there, you can iterate through the items or, you can use a method on the SPList object to turn it into a dataset which you could then use to generate a PDF using some kind of PDF library (e.g. PDF4NET). If you go this route the best way to roll it out is by packaging it up as a feature in a solution file (.WSP) which you can deploy to your farm. In this case the code would be running in the share point environment. You can get pretty fancy with this and have something like a "Print PDF" menu option in the action menu for all lists.

On the other hand, you could also access the list remotely using the web services. In such a case you could just use this as a data provider for your reporting package.