Home » 2009 » July

iTextSharp – HTML to PDF – Parsing HTML


Now that we have the HTML cleaned up, the next thing we will want to do is to parse the HTML.

In my actual code for this, I parse the HTML and create the PDF at the same time, but for the purposes of these posts, I’m going to deal primarily with parsing the HTML here and then deal with the PDF creation code later.

Continue reading “iTextSharp – HTML to PDF – Parsing HTML”

iText IN ACTION – Creating and Manipulating PDF


While this isn’t specifically targeted at iTextSharp, which we’ve been covering in recent posts, this is really the closest book you are going to find on the subject.

The basics are the same.  Keep in mind that the main difference is that setPropertyName and getPropertyName methods have been changed to .NET style properties (versus Java style) where it makes sense.  Method names start with a capital letter in iTextSharp, and event wiring is a little funky (we’ll get to that later).

Continue reading “iText IN ACTION – Creating and Manipulating PDF”

iTextSharp – HTML to PDF – Cleaning HTML


The last prerequisite step prior to actually converting our HTML into PDF code is to clean up the HTML.

The method I use takes advantage of the XML parser in .NET but in order to use that we have to have XHTML compliant XML.

For this exercise, what I am most concerned about is that the HTML tags all have matching closing tags, that the tags are nested in a hierarchical structure, and that the tags all are lower case.

Some of this we will have to rely on the user to provide, like properly nesting the tags.  But some of this we can attempt to clean up in our code.  If you know you will have complete control over your HTML, you might be able to skip this step.  But I think the code is simple enough that you’ll want to add it anyhow.

Continue reading “iTextSharp – HTML to PDF – Cleaning HTML”

Manually Adding Event Handlers in VB.NET


Typically when we write our code, the event handlers get wired up for us using the handles clause.  So we never have to worry about wiring up our event handlers manually.

But what about the case where we want to dynamically add a control to our Windows Form or our ASP.NET page?  For example, add a button.  How would you respond to the button click event?

Continue reading “Manually Adding Event Handlers in VB.NET”