Print On Canvas

Top  Previous  Next

If you want to combine the output of WPTools output and the output from another source on the same PDF page it is also possible to print on the PDF canvas from within WPTools.

You don't need the WPPDFExport component here, just a WPPDFPrinter.

 

Example Code:

 

procedure TForm1.ExportToPDF(Sender: TObject);

var i: Integer;

begin

 WPPDFPrinter1.AutoLaunch := TRUE;

 WPPDFPrinter1.FileName   := 'c:\pdf_from_canvas.pdf';

 WPPDFPrinter1.BeginDoc;

try

  for i := 0 to rtfDoc.CountPages - 1 do

  begin

     WPPDFPrinter1.StartPage(

       WPRichText1.Header.LayoutPIX.paperw,

       WPRichText1.Header.LayoutPIX.paperh,

       WPRichText1.Header.FFontXPixelsPerInch,

       WPRichText1.Header.FFontYPixelsPerInch,

      0);

     WPRichText1.PrintPageOnCanvas(

       WPPDFPrinter1.Canvas,

       Rect(0, 0,

            WPRichText1.Header.LayoutPIX.paperw,

            WPRichText1.Header.LayoutPIX.paperh),

       i,

       [ppmUseBorders],

      100);

     WPPDFPrinter1.EndPage;

  end;

finally

   WPPDFPrinter1.EndDoc;

end;

end;