Link to home
Start Free TrialLog in
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)Flag for Canada

asked on

How can I insert a RTF portion in the middle of a PrintDocument Page

The included .jpg shows a page that was created with a PrintDocument object. My problem is that some words in the portion that is marked with a red rectangle needs to be formatted with Bold, Italic and Underline characters.

Since the formatting is simple, I first tried using my own formatting tags and work from there. Not as easy as I thought.

I chose that recipe because I tried it last weekend, and it is a very good one for your taste buds (at least mine). So those of you who understand French can try it :-). Unfortunately most of the recipes used by the application have paragraphs that takes more than one line, and I need to handle word wrapping of the text so that it fits in the width of the page.

While word wrapping is quite easy to handle when all the text uses the same font, things get a lot more complicated when italic text is slightly larger, and bold text is about 30% wider than the same text in normal font.

To summarize, it can be done, but with pain that I would prefer not to endure. In my opinion, a good programmer is a lazy programmer. He does not work less than another one, but he does more during the same number of work hours. Since I see myself as a decent programmer, I am a bit lazy.

I then tried implementing the formatting in rtf, but found out that the PrintDocument cannot handle rtf by itself.

I tried displaying the rtf in a RichTextBox and insert a snapshot of that RichTextBox in the PrintDocument, but the quality is not good enough compared to the text in the rest of the document.

Did anybody ever had to format rtf text inside of a PrintDocument Page, or have an idea on an easy way to do it?

Thank you all.
Image2.jpg
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jacques Bourgeois (James Burger)

ASKER

Finally ended up interpreting the RTF myself in the PrintPage event of a PrintDocument.