#1 2015-08-28 07:14:07

ice1
Member
Registered: 2015-08-28
Posts: 1

[GDIPages] Page of Total Pages

I have a report code . I want to add in the footer information on the number of pages

procedure TForm5.Button3Click(Sender: TObject);
var i: integer;
begin
  with TGDIPages.Create(self) do
  try
  Orientation :=  poPortrait ;
    Caption := self.Caption;
    BeginDoc;
    AddTextToHeader('Wydruk za rok 2015');
    SaveLayout;
    Font.Style := [fsItalic];
    TextAlign := taRight;
    AddTextToFooter('http://synopse.info/');
    RestoreSavedLayout;
    AddTextToFooter('Data wydruku'+DateTimeToStr(Now));
    AddTextToFooterAt(PAGENUMBER,RightMarginPos); // Page of Total Pages
    // main content (automaticaly split on next pages)
    AddColumns([5,15,50]);
    AddColumnHeaders(['#','Two','Three'],true,true);
    WordWrapLeftCols := true;
    for i := 1 to 100 do
       if(i mod 2 = 0) then
            DrawTextAcrossCols([IntToStr(i),'Column '+IntToStr(i),'bardzo dlugi tekst i tak dalej dgdjh dfjgjdf djgfgdj dfjgdfjfd djdfj djfgfjdf ala ma kota kot ma ale oda do młodości'])
        else
            DrawTextAcrossCols([IntToStr(i),'Column '+IntToStr(i),'krótki tekst']);

    NewLine;
    DrawTitle('This is your text:');
    DrawText(mmo1.Text);
    EndDoc;
    ExportPDF('zaas.pdf',False,true);
  finally
    Free;
  end;
end;

Offline

#2 2015-08-28 12:21:34

eraldo
Member
From: Brasil
Registered: 2010-07-22
Posts: 69
Website

Re: [GDIPages] Page of Total Pages

Hello ice1,

in TGDIPages...


FluxBB bbcode test

Offline

#3 2015-08-28 12:37:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: [GDIPages] Page of Total Pages

Offline

#4 2018-07-20 13:46:18

squirrel
Member
Registered: 2015-08-13
Posts: 155

Re: [GDIPages] Page of Total Pages

Is it possible to specify on which pages AddPagesToFooterAt should apply or a starting page number from which it should be printed? When the pdf starts with a coverpage(s), it would be good to not print the footer on the first page.

Offline

#5 2018-07-21 08:13:25

squirrel
Member
Registered: 2015-08-13
Posts: 155

Re: [GDIPages] Page of Total Pages

Suggestion to make the above request possible:  Add an optional parameter to AddPagesToFooterAt to specify from which page number the "Page x / y" footers should be added, eg:

// StartAtPageNo is the page from which this footer will be added - 1 is the first page, not 0   
procedure AddPagesToFooterAt(const PageText: string; XPos: integer;  YPosMultiplier: integer=1; const StartAtPageNo: integer = 1);

    fPagesToFooterTextStartPage := StartAtPageNo;

which can be used in EndDoc when adding the footers:

  if (n>0) and (fPagesToFooterText<>'') and (fPagesToFooterTextStartPage-1 <= n) then
    // add 'Page #/#' caption at the specified position
    for i := (fPagesToFooterTextStartPage-1) to n-1 do begin

Offline

Board footer

Powered by FluxBB