Insert Page Number

  • The code I sued for WPTools 5 for inserting a page no in the footer no longer seems to work in WPTools7. However, it is the same code that appears at 45 of the pdf manual for WPTools 7. Any ideas? code is:

    var par : TParagraph;
    txtplain : Cardinal;
    begin
    par:=WPRichText1.HeaderFooter.Get(wpFooter,wpraOnAllPages).
    FirstPar;
    WPRichText1.WritingAttr.Clear;
    WPRichText1.WritingAttr.SetFontName('Courier New');
    WPRichText1.WritingAttr.SetFontSize(900); // 9pt
    txtplain := WPRichText1.WritingAttr.CharAttr;
    par.ClearText;
    par.ASet(WPAT_Alignment, Integer(paralRight));
    par.Insert(0,'Page ',txtplain);
    par.InsertNewObject(maxint, wpobjTextObject, false, false,
    txtplain).Name := WPTextFieldNames[wpoPageNumber];
    par.Insert(maxint,' of ',txtplain);
    par.InsertNewObject(maxint, wpobjTextObject, false, false,
    txtplain).Name := WPTextFieldNames[wpoNumPages];
    end;

    • Offizieller Beitrag

    The code is ok, it is a bit more complicated than usually necessary, since it operates directly on a paragraph. Without a ReformatAll the change will not be visible - if the header is visible at all.

    With

    WPRichText1.ActiveText := WPRichText1.HeaderFooter.Get(wpFooter,wpraOnAllPages);

    The cursor is in the header and it is possible to use InputString and InputTextField instead.