Fog Creek Software
Discussion Board




PDF Generator for .NET

I've got a project that will need a lot of PDF files and I wonder if anyone can recommend a .NET product to create them with.

The project is a web application and will replace an existing system that uses a lot of MS Word templates to generate documents (Letters, Certificates, Policy Schedules, etc). This works, but is very messy and requires lots of code to manipulate Word to get the data into the templates.

I would like to forget about Word, and the associated problems, and use something to generate PDF files, on the fly based upon data in the database.

It should be possible to create PDF files from scratch and manipulate the contents, adding paragraphs, tables, images, etc, all from within my C# class library.

Does anyone have any experience of this and which product(s) did you use ? What pitfalls, if any, should we look out for ?

Steve Jones (UK)
Wednesday, September 03, 2003

PDFlib is quite mature and supported on lots of languages/platforms: http://www.pdflib.com/products/languages.html

Chris Winters
Wednesday, September 03, 2003

For the forms that are templates then you might consider using Crystal Reports (ships with VS.NET) to generate the PDFs.

Mark Hoffman
Wednesday, September 03, 2003

Or you can generate an HTML page in whatever form you like, and then use HTMLDOC [ http://htmldoc.org ] to conver it. It works really well.

Ori Berger
Wednesday, September 03, 2003

Did PDFLib get around the ASP.Net appdomainunloaded issue? If not, then you can't use it from ASP.Net.

<brokenrecord>
ActiveReports will do everything you need - you have full control over the document; you can literally draw on it if you need to. Any report can be published to pdf
</brokenrecord>

Philo

Philo
Wednesday, September 03, 2003

Another happy ActiveReports.NET user here. Once you learn the basics it's all straightforward and works very well.

  --Josh

JWA
Wednesday, September 03, 2003

I have had great success using tallcomponents TallPDF.Net  http://www.tallcomponents.com/default.aspx?section=products&page=tallpdf/features.htm

It can take an XML document and and XSL document give you a  pdf very quickly.  This allows you to push a strongly typed data set through (GetXML()) with a xsl and end up with pdf.  Very little effort involved there.

K
Wednesday, September 03, 2003

One heads' up on strongly typed datasets, in case you weren't aware - you cannot have the same name on different entities. So this:

<Company>
<Address>...</Address>
</Company>
<Person>
<Address>...</Address>
</Person>

won't work. It's an easy workaround if you're still developing your schema - just go with <CompanyAddress> and <PersonAddress>. But if you have an established schema with that kind of problem, then no strongly typed datasets for you!

Philo

Philo
Wednesday, September 03, 2003

Thanks for the comments guys.

An additional requirement, that I forgot to mention earlier, is that the Users (only a few, not all of them) should be able to modify existing document templates and create their own document templates from scratch.

This needs to be from within the system, I think, so that they can access the data dictionary, etc.

I am thinking the templates will be made up of "fragments" of text, with variable formatting, interspersed with field markers, so that the field values can be substituted at runtime.

Steve Jones (UK)
Thursday, September 04, 2003

Philo regarding your heads-up -- are you sure? I was doubtful so just tried this. I created a DataSet XSD of the shape you specified and used the generated classes without a problem:

MyTypedDataSet ds = new MyTypedDataSet();
ds.ReadXml("c:\\temp\\data.xml");

foreach(MyTypedDataSet.CompanyRow company in ds.Company)
    Console.WriteLine(company.Address);

foreach(MyTypedDataSet.PersonRow person in ds.Person)
    Console.WriteLine(person.Address);

Duncan Smart
Thursday, September 04, 2003

I've used the PDF Printer Driver from Black Ice Software ( http://www.blackice.com ). It's got an API that you can use to basically do automatic Word -> PDF conversion on the fly, and I believe it's compatible with .NET, though I'm not sure to what extent.

Only disadvantage is it's quite expensive, which is okay if you're using it for shrinkwrap software (it's got a free runtime) and can recoup its costs that way, but less okay if it's used for a one off internal project.

Better Than Being Unemployed...
Thursday, September 04, 2003

Philo, ignore me -- if <Address> is a table (ie, with sub-elements such as <Town> <City> etc) rather than simply a value - you're right it won't work.

Duncan Smart
Friday, September 05, 2003

*  Recent Topics

*  Fog Creek Home