Hi, i have a problem with pdf's and wrapping text. I have a questionaire i want to export to a pdf. To make the layout readable for pdf's the text has to be wrapped. We have a microflow that after an certain number of characters puts in an <br /> tag in the text string. The problem i have with this microflow is that it doesn't take html tags into account. Sometimes you get tags in tags and then the pdf generates an error. For example something like this: <div<br />> I resolved this problem partially by stripping all html code from the input string. but i still have the html entities to deal with. Sometimes an " is in the input string to display as " in the pdf and then the same problem occurs: you get an string like this &qu<br \>ot; and the export to pdf fails. I want to keep those entities because otherwise the resulting text will be unreadable. i tried it with a regular expression, and i can filter on a html entity with that, i can even replace it with something. But i cannot keep these html entities into the text. Is there a way to put the matched string into a variable and use it in a later stadium? any suggestions onto how to solve this problem would be much appreciated. the function i used is RegexReplaceAll. and the regular expression is. ‘/&(?:[a-z\d]+|#\d+|#x[a-f\d]+);/i’
Jan Willem Maaskant
I would create counters with the value of the position of < and >. Then when the br counter reaches the point where the br tag should be placed check your < counter and > counter. If the < counter is higher than the > counter you should put the br at the place of the < counter.
Does this makes sense or should I elaborate a bit more?
Seems like this could be solved with a smart library that finds plain text in HTML. I would think there are a bunch out there. Getting this 100% right yourself will be fairly hard but you can probably get away with Ronalds suggestion and including some other special cases for all the html entities.
Are you sure this is the right place to solve this problem though? Why are the lines not just auto-wrapping in the exported documents? You can probably configure this explicitly using CSS but is there a reason? As far as I know the default will just be that can break on the end of a word.