Convert HTML to PDF

It’s not something I’ve done before, but my client needed to produce a quite complex order from for their customers and send it via email as a PDF document.  After a bit of searching to find a tutorial or some lead on how to accomplish this in ASP C#, I came across ABCpdf by WebSupergoo.

What really sparked my interest was that this particular ASP.Net HTML to PDF component does not use printer drivers to render the PDF document. This makes ABCpdf really fast which was essential as the PDF documents we were going to produce were several pages long.

The clincher for me was quite simple – the help pages.

When I’m working on something new, say utilising a third party API or a new C# concept, I like to see an example – a simple example. Many API or component help pages love to show you a complex block of code to get you started. A very good example of this is the Google maps API. Their example to place a pin on a map is how to place several random pins on a map, not the simple one pin, one map example. Thanks, that really helped!

Maybe I’m not that cleaver, but lets have the vanilla example first.

Well that’s exactly what WebSupergoo. Their CHM file that comes with the download is extensive and clearly laid out. Every major object method or property has an accompanying code sample. So it’s easy tog et started and before long you will be producing complex, on-the-fly PDF documents in no time at all!

Here is their first code snippet:

Doc theDoc = new Doc();
theDoc.FontSize = 96;
theDoc.AddText("Hello  World");
theDoc.Save(Server.MapPath("simple.pdf"));
theDoc.Clear();

Don’t let this simplicity fool you. It is very powerful indeed. You can precisely place any text or image on to the page, stitch other documents together and host of other cool features like streaming your documents direct to your client web browser without going via the disk.

Suffice it to say that I’m happy with ABCpdf and so is my client!

Post a comment

Copyright © Web Design Blog
web design by SiteOne

Built on Notes Blog Core
Powered by WordPress