Rendering a page break in WinForms RichTextBox
-
I have a project that integrates RichTextBox tips from many articles across the web. Everything from XP Style borders, to WYSIWYG printing. One thing missing is rendering of page breaks. I can insert an RTF page break that is visible when loading the resulting rtf file into Word, or similar. However I can't find how to render it inside the RichTextBox. I would like to render a nice dotted line at that point. So far my searches have only turned up print rendering articles, which I already have. Any suggestions or links to appropriate aticles would be welcome.
If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles] [My Website]
-
I have a project that integrates RichTextBox tips from many articles across the web. Everything from XP Style borders, to WYSIWYG printing. One thing missing is rendering of page breaks. I can insert an RTF page break that is visible when loading the resulting rtf file into Word, or similar. However I can't find how to render it inside the RichTextBox. I would like to render a nice dotted line at that point. So far my searches have only turned up print rendering articles, which I already have. Any suggestions or links to appropriate aticles would be welcome.
If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles] [My Website]
This is what I know about the matter, mostly from reading the RTF specification and from experimenting (I did quite some work on tables, perfectly readable in WordPad): - there are hundreds of RTF commands; - Word can create RTF documents, and will use a lot of the existing commands; - WordPad can create RTF documents, and will use only few of the existing commands; - WordPad can show a lot of RTF stuff it does not let you create interactively; - RichTextBox shows RTF documents pretty much the same as WordPad does. - RTF has a \page command - WordPad shows it as an empty line From that I would conclude: - by default RTB hardly renders a page command - you can of course add whatever text and formatting code you like whenever you also insert a page command; that is after all what Word does when it creates headers and footers for you. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
This is what I know about the matter, mostly from reading the RTF specification and from experimenting (I did quite some work on tables, perfectly readable in WordPad): - there are hundreds of RTF commands; - Word can create RTF documents, and will use a lot of the existing commands; - WordPad can create RTF documents, and will use only few of the existing commands; - WordPad can show a lot of RTF stuff it does not let you create interactively; - RichTextBox shows RTF documents pretty much the same as WordPad does. - RTF has a \page command - WordPad shows it as an empty line From that I would conclude: - by default RTB hardly renders a page command - you can of course add whatever text and formatting code you like whenever you also insert a page command; that is after all what Word does when it creates headers and footers for you. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
Thanks Luc I am using the
\page
command and it works fine when printing or loading into Word, just no visual cue in the RichTextBox. I hadn't realised WordPad did nothing to indicate the page break. If Microsoft left it out of WordPad I don't feel so bad about not implementing it myself. I guess the simplest solution will be for me to insert a horizontal line in place of any page breaks and replace them with real page breaks on save.If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles] [My Website]
-
Thanks Luc I am using the
\page
command and it works fine when printing or loading into Word, just no visual cue in the RichTextBox. I hadn't realised WordPad did nothing to indicate the page break. If Microsoft left it out of WordPad I don't feel so bad about not implementing it myself. I guess the simplest solution will be for me to insert a horizontal line in place of any page breaks and replace them with real page breaks on save.If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles] [My Website]
You're welcome.
The Man from U.N.C.L.E. wrote:
insert a horizontal line ... and replace them
That sounds OK. Whatever you want to achieve, it probably can be done, but you'll have to manipulate the RTF string yourself. FYI: as always, the document Word generates is overly complex; WordPad does a much better job, assuming it allows you to enter what you need. When working with tables, I looked at what Word does, read the RTF specs, and created it all in code, I didn't want hundreds of lines of initialization (and it gets worse in every new Office version). :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).