You are not logged in.
Pages: 1
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
Use TGDIPages.AddPagesToFooterAt() method.
http://synopse.info/files/html/api-1.18 … TOFOOTERAT
See e.g. in sample https://github.com/synopse/mORMot/blob/ … Client.pas
Offline
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
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
Pages: 1