Different header and footer depending on text on page:

    • Offizieller Beitrag

    Create different header and footer as 'named' text:

    Code
    // Generate simplyfied header and footer  WPRichText1.HeaderFooter.Get(wpIsHeader, wpraNamed, 'ONE').RtfText.AsString :=    'Dies ist der Header ONE';  WPRichText1.HeaderFooter.Get(wpIsHeader, wpraNamed, 'TWO').RtfText.AsString :=    'Dies ist der Header TWO';  WPRichText1.HeaderFooter.Get(wpIsHeader, wpraNamed, 'THREE').RtfText.AsString :=    'Dies ist der Header THREE';  WPRichText1.HeaderFooter.Get(wpIsFooter, wpraNamed, 'ONE').RtfText.AsString :=    'Dies ist der Footer ONE';  WPRichText1.HeaderFooter.Get(wpIsFooter, wpraNamed, 'TWO').RtfText.AsString :=    'Dies ist der Footer TWO';  WPRichText1.HeaderFooter.Get(wpIsFooter, wpraNamed, 'THREE').RtfText.AsString :=    'Dies ist der Footer THREE';

    In the event WPRichText1GetSpecialText you can activate one of the above texts using this code:

    Code
    if WPFindTxtOnPage(WPRichText1,par,lin,'ONE',true) then  begin     SpecialText := WPRichText1.HeaderFooter.Get(Kind, wpraNamed, 'ONE');  end  else if WPFindTxtOnPage(WPRichText1,par,lin,'TWO',true) then  begin     SpecialText := WPRichText1.HeaderFooter.Get(Kind, wpraNamed, 'TWO');  end ..

    The code above uses an utility function which checks if a certain text exists within one line on a certain page. If 'scan=true' it finds the text anywher in the line, otherwise only at the start.

    NOTE: This unit will be in V4.2a and higher (unit WPRich.PAS)

  • The code provided was implemented to get special text and four keywords were used to search for the header footers. Each keyword was found on the page and during print preview the headers and footers could be viewed but not in the open body of the editor.

    When placing a keyword such as "ONE" on a page and backspacing out letters it could be seen that a print change was occuring in the header, and a small blur appeared as if the system was trying show the header. The blur would disappear when the full word was typed, for example as ONE; once the last letter was typed, the header cleared indicating that the read of the keyword was successful.

    How can I get the headers and footers using code as provided in the solution to show in the body of the editor?