#1 Re: PDF Engine » SynPdf - Select active page / canvas » 2023-04-27 09:58:36

Thank you for the answer, rvk! I have already checked some parts of the source code but since I believed there is a way to do that and I'm missing it, I preferred not to mess with it. If there are no other possibilities I guess I'll have to try and modify some parts according to my needs. Thank you once again!

Edit: Just tried commenting the aforementioned lines and at first look it works using RawPages and SetPage.

#2 PDF Engine » SynPdf - Select active page / canvas » 2023-04-26 11:27:04

nnmnnm
Replies: 2

Hello,

I'm using SynPdf and after adding a few pages and drawing some objects / text on each page canvas I would like to return to page number 1 for example and write some additional text (like page number / total pages). I cannot find any example how to do that. I'm doing something like that:

var
  pdf: TPdfDocumentGDI;
  page: TPdfPage;
begin
  pdf := TPdfDocumentGDI.Create;

  // page 1
  page := pdf.AddPage;

  pdf.VCLCanvas.Font.Name := 'Times New Roman';
  pdf.VCLCanvas.Font.Size := 24;
  pdf.VCLCanvas.TextOut(100, 100, 'some text on page 1');

  // page 2
  page := pdf.AddPage;

  pdf.VCLCanvas.Font.Name := 'Times New Roman';
  pdf.VCLCanvas.Font.Size := 24;
  pdf.VCLCanvas.TextOut(100, 100, 'some text on page 2');

  // write some text back to page 1
  ...
end;

I have tried something like this but it clears the entire page contents and obviously that's not the correct way to do it:

  ...
  //
  page := pdf.RawPages[0]; // select page 1

  //
  pdf.Canvas.SetPage(page); // set active canvas to page 1
   ...

Any help would be appreciated.

Board footer

Powered by FluxBB