We are using WebSupergoo’s ABCPDF to render HTML as PDF documents in our application. In general, it’s not bad. However, like all third party components, stretching it outside the box is almost more difficult than it would have been to just write the damn thing from scratch. The “80-20” rule is alive and well here, and we’ve had to make several modifications to our exportation code to give our users exactly what they want.
But I don’t want to rant and rave about ABCPDF in this post; PDF exportation is propitiatory, and WebSupergoo does make this a fairly easy process. All I want to do is point out one issue I just figured out to hopefully save everyone from suffering the same headache.
For those of you who use this tool, you are used to its HTML parser. Keep in mind that this is different than your browser’s parser. We develop internal software, so cross-browser compatibility usually only means that the app has to look good both in IE 6 and IE 7, and that we can get away with IE-only goodies, such as the onmouseleave event.
Another such “goodie” is the gradient filter. This allows IE to call directly into DirectX and provide dynamic gradients that really spruce up your page. However, like I said, this is IE only, which means other browsers (including ABCPDF’s HTML parser) can’t use it.
So the issue we were having is that when I was embedding our stylesheets in into our HTML in code, I kept getting an ABCPDF exception that told me nothing more than “HTML to render is blank.” This is the panacea that ABCPDF seems to throw whenever it doesn’t like the HTML you pass to AddImageHTML. Rarely, is the problem actually a blank HTML string. This will be the exception you get whenever unsupported markup is provided.
This took me a while to figure out, because I was going down the path that I actually had invalid (vs. unsupported) HTML. And, admittedly, being used to IE pitching in and closing unclosed tags (and other problems) for you, I tend to forget to check for such an error. So when it popped up, I assumed that ABCPDF’s parser has a little more stringent, and I was just doing something dumb.
But, no, I was just doing something unsupported. So checkout WebSupergoo’s website, where they document exactly which HTML tags they support. My experience: stay away from any “IE goodies” when exporting to PDF via this tool. Have fun!