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

  • 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:

    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

  • Zitat von 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.

    • Offizieller Beitrag
    Zitat

    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

  • Zitat von 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