-
Dim K
- PowerBuilder
- Thursday, 9 October 2025 08:36 AM UTC
I have some stored RTF documents that were originally saved without headers or footers.
Now i want to print them with a header and footer.
I tried the following three approaches:
1. Using the RichTextEdit control
I attempted something like this:
https://docs.appeon.com/pb2025/powerscript_reference/showHeadFoot_func.html
rte_doc.ShowHeadFoot(true, false)
rte_doc.SetAlignment(Center!)
rte_doc.InputFieldInsert("PAGENO")
rte_doc.ShowHeadFoot(false, false)
However, when i import an existing RTF document and try to use this, it doesn’t work correctly
the page number does not appear.
If the document is empty, the page numbering displays fine.
(The existing documents do not have header/footer sections.)
2. Using an OLE object with Microsoft Word
This works fine !!
I load the RTF into a temp file, open it in an OLE Word object, and then add the header/footer there.
But i don’t want my application to depend on a system-level application like Word,
so i moved to another approach.
3. Using a DataWindow (RTF)
I created a datawindow -> dw_rtf.
I take the detail section from the RichText control using:
ls_detail_rtf = rte_doc.CopyRTF(false, Detail!)
dw_rtf.PasteRTF(ls_detail_rtf, Detail!)
For the header, i insert the following:
ls_header_rtf = "{\rtf1\ansi\ansicpg1253\uc1\deff1{\fonttbl{\f0\fswiss\fcharset161 Arial Greek;}}" + & "\fs20 \pard\qc Title : " + String(is_title) + "\par}" dw_rtf.PasteRTF(ls_header_rtf, Header!)
For the footer, i want to display page number and date/time.
I noticed that dw_rtf has two computed fields one for date and one for page number.
However, when i print, the result i get for both is just ??
This is an example using the computed field for page numbers.
this is the output :
any ideas ;
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.