Generating PDF documents From C# Code

I recently had a requirement to convert an outlook calendar file into a printable diary. It was fairly easy to export the calendar into a format readable by C# code, but I didn’t expect it to be so easy to dynamically generate a PDF booklet from this data.

I looked at a few PDF toolkits based on suggestions on this page but by far the best in my opinion was PDFSharp. It simply allows you to dynamically create a PDF document, add pages to it and to draw or write whatever you want at any position on the page.

I managed to write a program that looped over my dataset and outputted separate odd and even pages (one per week) in a one (admittedly long) evening.

It would be a really good tool for any problem where you have to generate non-standard reports or documents from a data set, where you need complete control of what goes on the page. I must admit that I’m quite keen do do more with it.

 

Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *