#2 PDF Engine » PageSize on TPdfDocument GDI » 2011-12-18 14:06:38

Papy214
Replies: 2

HI,

I use the code :

procedure TForm1.btnPDFClick(Sender: TObject);
var
  fichier: string;
  testpdf:TPdfDocumentGDI;
  page: TPdfPage;
  bmp: TBitmap;
begin

  if not PromptForFilename(fichier) then
    Exit;

  testpdf := TPdfDocumentGDI.Create;
  try
    testpdf.NewDoc;
    testpdf.DefaultPaperSize := psA4;
    try
      page := testpdf.AddPage;
      testpdf.ForceJPEGCompression := 75;
      bmp := TBitmap.Create;
      bmp.LoadFromFile(fichier);
      testpdf.VCLCanvas.StretchDraw(Rect(10, 10, page.PageWidth - 20, page.PageWidth - 20), bmp);
      bmp.free;

    finally
      testpdf.SaveToFile('d:\test.pdf');
    end;
  finally
    testpdf.Free;
  end;

end;

But the pageSize is not correct. The margins are not good. The image is only on a half part of page.

How can I get the real pagesize to adjust the picture to the page please ?

Papy

Board footer

Powered by FluxBB