StartPage

Top  Previous  Next

Creates an new page in the PDF file. The Canvas property is not valid unless you execute StartPage or StartWatermark.

 

Please note that there is no need to execute StartPage if you only export an enhanced metafile (DrawMetafile). In this case the engine will open a page and close it after the data has been exported.

 

The parameters of StartPage are the size of the page (width and height) and the resolution the values are measured in. If you use twips values set the resolution to 1440, if you are using the Width/Height of the current form use Screen.PixelsPerInch. The Resolution the PDF engine will use will be changed accordingly!

 

The parameter options can be used to rotate the page. Possible values are 0, 90, 180 and 270.

 

NOTE: The resolution parameter does per default not change the resolution of the PDFPrinter.Canvas. But it changes the resolution of the PDF file. The default resolution of PDF files is 72 which is a good value for text.  wPDF V2 also changes the resolution of the 'Canvas' using the SetViePortAPI.

 

You can use this formula to set the width and height accordingly to the values you are using in screen coordinates:

 

StartPage(

          MulDiv(Width,72,Screen.PixelsPerInch),

          MulDiv(Height,72,Screen.PixelsPerInch),72,72,0);

 

 

To set a certain resolution (res) in the canvas property use this code:

 

 DC := WPDFPrinter1.Canvas.Handle;

 curr_resX := GetDeviceCaps(DC,LOGPIXELSX);

 curr_resY := GetDeviceCaps(DC,LOGPIXELSY);

 SetMapMode(DC, MM_ANISOTROPIC);

 SetWindowExtEx(DC, res, res, nil);

 SetViewPortExtEx(DC, curr_resX, curr_resY, nil);

 SetViewPortOrgEx(DC, 0, 0, nil);

 

 

Note: If you only want to export a metafile you don't need to execute StartPage. The procedure DrawMetafile will automatically create a PDF with the correct dimensions.