My first suggestion would be: use google!
There are already scripts/executables that can convert HTML to PDF which are bound to be more efficient than your method (other people always think of better methods :-) )
If that doesn't help, I'd take out the most time-consuming bits.
First, take out the on-the-fly processing of the content. Instead, do the processing only when the content changes, and store the processed data in the database next to the original.
So instead of storing
<b>this is bold text</b> with some plaintext
just store:
bold:this is bold text
plain: with some plain text
Then when you need the data, you can load the pre-processed data and just bang it into PDF. The first word is the font type (you can add more info if required) and the rest is the actual content. That is much faster than doing it char-by-char every time.