Hello,
I've been looking at Spire.PDF (.NET) for a project where I need to produce product datasheet downloads in PDF format, from product data stored in a database.
On the whole, I've managed to get a nice result so far - but have come across a problem with interpreting text with HTML tags.
We need to organise the product description in to three columns, which I've achieved using PdfStringLayouter - I break up the product description in to paragraphs, which I feed in to PdfStringLayouter.Layout(). Each line of the result is then output using the DrawString function, and I maintain/check the vertical position on the page after each line, to decide when a column break is required.
With plain text, this works absolutely fine.
However, our product description contains some basic HTML tags (e.g. <strong>, <b>, <u>) which are used to highlight certain key words or phrases.
It seems that PdfStringLayouter is not able to interpret HTML tags, even though DrawString is able to (htmlTags boolean parameter).
We found that DrawString correctly interprets basic HTML tags (and makes the necessary adjustments in the text - e.g. setting chunks of content to bold type). However, because PdfStringLayouter doesn't recognise HTML tags (and includes them verbatim when creating the layout) it breaks the layout.
Just wondered if there was a work around for this? Is there some way of using PdfStringLayouter to get the line breaks in the right place by passing in a plain text version of a paragraph, and somehow using that result to calculate the correct portion of the string with the HTML tags to pass to DrawString?
Or, is there a way of telling PdfStringLayouter to ignore HTML tags when calculating the line breaks? (whilst still maintaining them in the output)?
Any tips greatly appreciated!
Thanks,
Steve.