Demo: Page background and border in RTF and DocX

Microsoft Word Documents (DocX and RTF) do not support page background directly.
However, there is a workaround: you can insert a text box in a header or a footer, and add an image to this textbox. Additionally, this textbox can have a border.
Actually, Microsoft Word itself uses this technique when adding a page watermark.

The demo shows how to generate a document having a page border and a page background image, and how to same it to DocX and RTF files. The demo can be found in the support forum: https://www.trichview.com/forums/viewtopic.php?t=10793

There are 4 versions of the demo: (for TRichView and for ScaleRichView) x (for Delphi and for C++Builder 11)
The demos for C++Builder 11 can be used in older versions of C++Builder, you just need to change references to packages in the CBProj file.

Note 1: A text box is positioned relative to the whole page, its size and position is calculated in absolute values (depending on the page size and margins).
Why don’t we used sizing and positioning relative to the main text area? It was done for compatibility with Libre Office. Unfortunately, its current version has problems with advanced options for textbox positioning.

Note 2: This demo shows the simplest case: the same background image for all pages. TRichView and ScaleRichView support special headers for the first page and odd/even pages, so they can have different background images and borders.

Sergey Tkachenko

Share
Published by
Sergey Tkachenko

Recent Posts

ANN: IDEInstaller 2.5

IDEInstaller 2.5 includes support for 64-bit Delphi IDE.

1 week ago

ANN: TRichView 23.2 – Markdown in Clipboard

We have released TRichView 23.2 and updates of related components The main new feature in…

2 weeks ago

ANN: RVMedia 11.1 – error handling and UDP streaming

RVMedia 11.1 has been released Main new features: UDP streaming with FFmpeg improved error handling…

3 weeks ago

TRichView 23.1 – RichViewActions for Lazarus for Linux

We have released TRichView 23.1 and updates of related components The main new feature in…

3 months ago

IDEInstaller v2.4

We've released our installer program as freeware with source code:http://www.trichview.com/ideinstall/ It was updated to version…

4 months ago

TRichView 23 – Lazarus for Linux, equations in files

We have released TRichView 23 and updates of related components This update is free for…

4 months ago