WPCubed Product Support

Page Oritentation for Entire Document

Hi, I'm trying to change the page orientation for all pages of a document (spanning 1-500+ pages). By default, it is in Portrait and I want to change the page setup so that it's to be Landscape, with the following code:


RTFDocument.PaperDefs.Init(true);
wpPageSetup.EditBox := RTFDocument;

if wpPageSetup.Execute then begin
RTFDocument.Header.Select := [wpsec_Margins, wpsec_PageSize];
RTFDocument.PaperDefs.Init(true);
RTFDocument.ReformatAll;
RTFDocument.Invalidate;
end;


This works fine for the first page, but all following pages still are still Portrait.

What other settings do I need to set to change all pages and not just the first? I also tried using the OnMeasureTextPage with the following code which did not work either:


if RTFDocument.Header.Landscape then begin
PageInfo.heighttw := RTFDocument.Header.PageWidth;
PageInfo.widthtw := RTFDocument.Header.PageHeight ;
PageInfo.changed := true;
end else begin
PageInfo.heighttw := RTFDocument.Header.PageHeight;
PageInfo.widthtw := RTFDocument.Header.PageWidth ;
PageInfo.changed := true;
end;


Any help would be greatly appreciated.

Luke

#1 ♥ 0
5.6k Views 3 users read 3 min

Luke,

Greetings..🙂

I might be missing something glaringly obvious to everyone ELSE in your sample code, but nowhere did I see what I was expecting to see in your code:

RTFDocument.Header.Landscape := TRUE;

Have you tried that? The statement can go just about anywhere, although near the top, where you initialize the document (but probably after any Clear).

That do you? And apologies if I'm not understanding your question!
richard diamond

#2 ♥ 0

@JazzMan:
Luke,

Greetings..🙂

I might be missing something glaringly obvious to everyone ELSE in your sample code, but nowhere did I see what I was expecting to see in your code: RTFDocument.Header.Landscape := TRUE;

richard diamond

Thanks Richard,

After bringing up the Printer dialog (using a TWPPagePropDlg) and selecting Landscape, the RTFDocument.Header.Landscape equals TRUE. Unfortunately this is only the case for the first page as the remaining pages are all in Portrait.

Cheers, Luke.

#3 ♥ 0
support

I'm trying to change the page orientation for all pages of a document (spanning 1-500+ pages).

WPRichText1.Header.Landscape := true;

should do it - if there are no sections.

If there are sections you need to undefine the page size definitions for all sections.

for i:=0 to WPRichText1.HeaderFooter.SectionPropertyCount-1 do
WPRichText1.HeaderFooter.SectionProperty[i].Select :=
WPRichText1.HeaderFooter.SectionProperty[i].Select - [wpsec_PageSize];

Julian

#4 ♥ 0

@wpsupport:
for i:=0 to WPRichText1.HeaderFooter.SectionPropertyCount-1 do
WPRichText1.HeaderFooter.SectionProperty[i].Select :=
WPRichText1.HeaderFooter.SectionProperty[i].Select - [wpsec_PageSize];

Julian

Thanks Julian, That did the trick!

Cheers, Luke

#5 ♥ 0
This category is archived. No new posts are possible.