I have read a lot about RTF data and StyledText, and how to display RTF data in a TextArea, and in fact this is no more a problem.
But I haven’t found anything about printing RTF data (or maybe I haven’t seen the answer).
In a SQL Server table I have stored RTF data in a field, and it looks like this:
{\rtf1\ansi\ansicpg1252{\fonttbl{\f0\fnil Verdana;}}{\colortbl\red0\green0\blue0;}\uc0 \ql\f0\fs22 This is \b Bold \b0 text.This is \i Italic \i0 text.And this is \ul Underline \ul0 text.This is \b\i Bold+Italic\b0\i0 text.}
Well, I can display it correctly in a TextArea using txtArea.StyledText.RTFData, but I am in trouble when I have to print the same data.
The trouble is that I don’t know how to print RTF data; in other words I don’t know how to transform the control chars into, for example, bold, italic, underline words.
I am using the built in report tool and Windows 10.
So you want to print the rendered RTF, not the raw RTF? Your OP talked about printing RTF data so I assumed you had the RTF in a string and wanted to print that. Would this help:
Did you tried FTC ? I’m sure it can offer you all the tools you need, we are using that for many years and it just does the job. Formatted Text Control – BKeeney Software Inc. I’m not sure still available but for sure it still is.
Thank you Aurelian & Sam: I have no problems with text area, I have problems with Report (I can’t print formatted text).
Aurelian, I think the BKeeney’s Formatted Text Control is for windows and not for printing.
With FTC you can print documents too since it uses the normal Graphics Object. You can download the sample App from www.bkeeney.com and try it. Printing is implemented.
Ok Sam: I have to print a field from a database table; this field contains text in RTF format like this. {\rtf1\ansi\ansicpg1252{\fonttbl{\f0\fnil Verdana;}}{\colortbl\red0\green0\blue0;}\uc0 \ql\f0\fs22 This is \b Bold \b0 text.This is \i Italic \i0 text.And this is \ul Underline \ul0 text.This is \b\i Bold+Italic\b0\i0 text.}
I have to print the formatted text in a Reportfield. I am using the Report built in object, so I can’t use a TextArea (I think I can’t use, but I’m not sure I’m right).
If I had to display the formatted text in a Textarea it would be quite simple…
If you’re on macOS you could put the RTF data into a hidden text area, size it the same as your printer and then call TextArea1.drawInto(g,0,0)
This only works if there is no scrolling.