Preview and printing

The user can preview the layout and print the contents of the RichTextEdit control. In preview mode, users see a view of the document reduced so that it fits inside the control. If the control is small, the preview is tiny.

There are two ways to enter preview mode:

Adjusting the print margins

A user can adjust the margins of the preview mode by opening the property sheet for the RichTextEdit control to the Print Specifications tab and modifying the left, right, top, or bottom margins. Adjusting the margins in the Rich Text Object dialog box also affects the display of the RichTextEdit control content in standard view.

The left side of the sample preview screen has width and height boxes for entering paper size, boxes for setting left, right, top, and bottom margins, and arrow keys for changing the number of the page displayed. The right side of the screen displays a reduced preview image of the formatted page.

Printing

If the RichTextEdit is using DataWindow object data, you can limit the number of rows printed by setting the Print.Page.Range property for the DataWindow control. Its value is a string that lists the page numbers that you want to print. A dash indicates a range.

Example of a page range Suppose your RichTextEdit control has a data source in the control dw_source. Your rich text document is three pages and you want to print the information for rows 2 and 5. You can set the page range property before you print:

dw_source.Object.DataWindow.Print.Page.Range = &
   "4-6,13-15"

You can also filter or discard rows so that they are not printed.

For more information, see the SetFilter, Filter, RowsMove, and RowsDiscard functions in the PowerScript Reference and the Print DataWindow object property in the DataWindow Reference.

Setting the page number

To print page numbers, you can use an input field in the header or footer. Although the page number field can be a string or numeric expression, when you insert the page number field in a header or footer, you must use it as a string expression only. For example, if you use page()*2 for an input field in the header or footer, the control or report is likely to display an incorrect result for the value of the numeric expression. However, the following string expression should display the correct page number and page count:

'Page ' + page() + ' of ' + pageCount())

Inserting footer text programmatically

This sample code sets the insertion point in the footer and inserts two blank lines, text, and two input fields:

rte_1.SelectText(1, 1, 0, 0, Footer!)
rte_1.ReplaceText("~r~n~r~nRow ")
rte_1.InputFieldInsert("row")
rte_1.ReplaceText(" Page ")
rte_1.InputFieldInsert("page")
rte_1.SetAlignment(Center!)