Yet Another Code Site |
Full-featured word processors allow users to insert page-breaks at arbitrary locations in documents. However, you will find no such feature in most applications based Rich Edit controls.
The Rich Text Format (RTF) specification does, in fact, contain an RTF code for page-breaks ("\page"). Unfortunately, Rich Edit controls (versions 1.0 - 3.0) simply ignore it. (In fact, I think that version 1.0 actually removes the \page code or changes it to a paragraph.)
This part of the paper describes a way to implement page-breaks. It builds on the prior three parts of the paper so, if you have not studied them, you should do so now.
The technique that I finally implemented is pretty straight-forward -- and more than a bit ugly. To be fair, it is more a "proof of concept" than a polished implementation. It requires the user to type a specific sequence of characters wherever he or she wants a page-break to occur. This marker is:
<< Page Break >>
Note that the user must key this exactly, spaces and all. However, it is not case sensitive.
When printing or previewing the document, we search the text for the marker and build a list of locations where it appears in the document. Then we build the list of pages, limiting the range to be rendered to the sections of text before, between, and after the markers.
I will not go into great detail here since it should be fairly clear in the code (available below). However, this technique is, as I mentioned, not pretty. Here are my suggestions on how you might improve it.
If you implement any of these suggestions, please let me know -- I would love to see the results.
Back to Part 3: Printing Rich Edit Controls
The complete BCB 4.0 project for all four parts of this paper is available for download. If you have BCB 3.0, you can still use the code, but you will need to grab the BCB 3.0 project from Part 3 of this paper and copy parts of the source code from this project back into it.
Home | Top Of Page | Code | Papers | FAQs | Links | Search | Feedback |
Page updated |
Copyright © 1999-2001 Thin Air Enterprises and Robert Dunn. All rights reserved.