Object

PrinterSetup Class

Used to get and set the page setup settings.

Properties
Height | PageHeight | Top
HorizontalResolution | PageLeft | VerticalResolution
Left | PageTop | Width
MaxHorizontalResolution | PageWidth |
MaxVerticalResolution | SetupString |

Methods
PageSetupDialog

# Notes

Passing a PrinterSetup object to the OpenPrinter or OpenPrinterDialog functions will cause the printer to utilize those PrinterSetup object's properties when printing. For example, if the user chose 200% for the scale in the Page Setup dialog box, the printer would automatically print at 200%.

The Page Setup dialog is not supported on Linux builds. Calling this function will return False with no dialog presented to the user.

MaxHorizontalResolution and MaxVerticalResolution

These properties enable you to print at higher resolutions than 72 dpi. In general, you will need to scale the material being printed (and perhaps the size of the controls) to get the desired results. For example, if you are printing styled text in an EditField using DrawBlock, you will need to make commensurate changes to the font size(s) to get WYSIWYG output. Doubling the resolution will require that you double the font size; otherwise you will get text that is half the size of the screen font.

# Examples

This example displays the Page Setup dialog box then stores the settings the user chose in a variable:

Dim settings as String
Dim PageSetup as PrinterSetup
PageSetup= New PrinterSetup
If PageSetup.PageSetupDialog Then
settings=PageSetup.SetupString
End If

This example restores the page setup settings stored in a variable called "settings" and then displays the Page Setup dialog box with those settings

Dim PageSetup as PrinterSetup
PageSetup= New PrinterSetup
PageSetup.SetupString=settings
If PageSetup.PageSetupDialog Then
settings=PageSetup.SetupString
End If

:

This example displays the Page Setup dialog box and then passes the settings the user chose to the OpenPrinterDialog function. It then prints a sample string:

Dim g as Graphics
Dim p as PrinterSetup
p= New PrinterSetup
If p.PageSetupDialog then
g= OpenPrinterDialog(p)
If g<> Nil then
g.DrawString "Hello World", 50,50
End if
End if

This example displays the Page Setup box and then displays the page size, printable area, and margins in StaticText controls. Results, of course, depend on the page size that the user selects. Since PageLeft and PageTop are the horizontal and vertical margins as measured from the printable area rather than the edge of the page, they are negative.

Dim settings as String
Dim p as PrinterSetup
p= New PrinterSetup
If p.PageSetupDialog Then
settings=p.SetupString
End If
staticText1.text="PageLeft="+ Str(p.pageLeft)
staticText2.text="PageTop="+ Str(p.pagetop)
staticText3.text="PageHeight="+ Str(p.pageheight)
staticText4.text="PageWidth="+ Str(p.pagewidth)
staticText5.text="Height="+ Str(p.Height)
staticText6.text="Width="+ Str(p.width)
staticText7.text="Computed height="+ Str(p.height-2*p.pagetop)
staticText8.text="Computed width="+ Str(p.width-2*p.pageleft)

# See Also

Graphics, StyledTextPrinter classes; OpenPrinter, OpenPrinterDialog functions.