Class

# PrinterSetup

<div class="rst-class">

forsearch

</div>

Printing

<div class="rst-class">

forsearch

</div>

Print

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to get and set the page setup settings.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                                    | Type                               | Read-Only | Shared |
|-------------------------------------------------------------------------|------------------------------------|-----------|--------|
| `Height<printersetup.height>`                                           | `Integer</api/data_types/integer>` | ✓         |        |
| `HorizontalResolution<printersetup.horizontalresolution>`               | `Integer</api/data_types/integer>` | ✓         |        |
| `Landscape<printersetup.landscape>`                                     | `Boolean</api/data_types/boolean>` |           |        |
| `Left<printersetup.left>`                                               | `Integer</api/data_types/integer>` | ✓         |        |
| `MaximumHorizontalResolution<printersetup.maximumhorizontalresolution>` | `Integer</api/data_types/integer>` |           |        |
| `MaximumVerticalResolution<printersetup.maximumverticalresolution>`     | `Integer</api/data_types/integer>` |           |        |
| `PageHeight<printersetup.pageheight>`                                   | `Integer</api/data_types/integer>` | ✓         |        |
| `PageLeft<printersetup.pageleft>`                                       | `Integer</api/data_types/integer>` | ✓         |        |
| `PageTop<printersetup.pagetop>`                                         | `Integer</api/data_types/integer>` | ✓         |        |
| `PageWidth<printersetup.pagewidth>`                                     | `Integer</api/data_types/integer>` | ✓         |        |
| `Settings<printersetup.settings>`                                       | `String</api/data_types/string>`   |           |        |
| `Top<printersetup.top>`                                                 | `Integer</api/data_types/integer>` | ✓         |        |
| `VerticalResolution<printersetup.verticalresolution>`                   | `Integer</api/data_types/integer>` | ✓         |        |
| `Width<printersetup.width>`                                             | `Integer</api/data_types/integer>` | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                    | Parameters                                                                                                    | Returns                            | Shared |
|---------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|------------------------------------|--------|
| `OpenPrinter<printersetup.openprinter>`                 | setup As PrinterSetup                                                                                         | `Graphics</api/graphics/graphics>` | ✓      |
| `ShowPageSetupDialog<printersetup.showpagesetupdialog>` | `Optional</api/language/optional>` parentWindow As `DesktopWindow</api/user_interface/desktop/desktopwindow>` | `Boolean</api/data_types/boolean>` |        |
| `ShowPrinterDialog<printersetup.showprinterdialog>`     | `Optional</api/language/optional>` parentWindow As `DesktopWindow</api/user_interface/desktop/desktopwindow>` | `Graphics</api/graphics/graphics>` |        |

## Property descriptions

<div id="printersetup.height">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.Height

**Height** As `Integer</api/data_types/integer>`

> The height of the printable area on the page (in pixels). The height is the PageHeight minus the margins.
>
> This property is read-only.
>
> This example displays the Page Setup box and then displays the page size, printable area, and margins in Label 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.
>
> ``` xojo
> Var settings As String
> Var p As New PrinterSetup
>
> If p.ShowPageSetupDialog Then
>   settings = p.Settings
> End If
>
> Label1.Text = "PageLeft=" + p.PageLeft.ToString
> Label2.Text = "PageTop=" + p.PageTop.ToString
> Label3.Text = "PageHeight=" + p.PageHeight.ToString
> Label4.Text = "PageWidth=" + p.PageWidth.ToString
> Label5.Text = "Height=" + p.Height.ToString
> Label6.Text = "Width=" + p.Width.ToString
> Label7.Text = "Computed height=" + Str(p.Height - 2 * p.PageTop)
> Label8.Text = "Computed width=" + Str(p.Width - 2 * p.PageLeft)
> ```

<div id="printersetup.horizontalresolution">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.HorizontalResolution

**HorizontalResolution** As `Integer</api/data_types/integer>`

> The horizontal resolution in dots per inch of the output device (usually a printer).
>
> This property is read-only.
>
> This example displays the Page Setup box and then displays the page size, printable area, and margins in Label 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.
>
> ``` xojo
> Var settings As String
> Var p As New PrinterSetup
>
> If p.ShowPageSetupDialog Then
>   settings = p.Settings
> End If
>
> Label1.Text = "PageLeft=" + p.PageLeft.ToString
> Label2.Text = "PageTop=" + p.PageTop.ToString
> Label3.Text = "PageHeight=" + p.PageHeight.ToString
> Label4.Text = "PageWidth=" + p.PageWidth.ToString
> Label5.Text = "Height=" + p.Height.ToString
> Label6.Text = "Width=" + p.Width.ToString
> Label7.Text = "Computed height=" + Str(p.Height - 2 * p.PageTop)
> Label8.Text = "Computed width=" + Str(p.Width - 2 * p.PageLeft)
> Label9.Text = "Horizontal resolution=" + p.HorizontalResolution.ToString
> Label10.Text = "Vertical Resolution=" + p.VerticalResolution.ToString
> ```

<div id="printersetup.landscape">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.Landscape

**Landscape** As `Boolean</api/data_types/boolean>`

> Gets and sets the landscape state of the <span class="title-ref">PrinterSetup</span> object. It is `True</api/language/true>` for the landscape orientation; `False</api/language/false>` otherwise.
>
> This example sets the Landscape property.
>
> ``` xojo
> Var settings As String
> Var p As New PrinterSetup
>
> If p.ShowPageSetupDialog Then
>   settings = p.Settings
> End If
>
> p.MaximumHorizontalResolution = 300
> p.MaximumVerticalResolution = 300
> p.Landscape = True
> ```

<div id="printersetup.left">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.Left

**Left** As `Integer</api/data_types/integer>`

> The left origin of the printable area. This should always be zero.
>
> This property is read-only.
>
> This example displays the Page Setup box and then displays the page size, printable area, and margins in Label 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.
>
> ``` xojo
> Var settings As String
> Var p As New PrinterSetup
>
> If p.ShowPageSetupDialog Then
>   settings = p.Settings
> End If
>
> Label1.Text = "PageLeft=" + p.PageLeft.ToString
> Label2.Text = "PageTop=" + p.PageTop.ToString
> Label3.Text = "PageHeight=" + p.PageHeight.ToString
> Label4.Text = "PageWidth=" + p.PageWidth.ToString
> Label5.Text = "Height=" + p.Height.ToString
> Label6.Text = "Width=" + p.Width.ToString
> Label7.Text = "Computed height=" + Str(p.Height - 2 * p.PageTop)
> Label8.Text = "Computed width=" + Str(p.Width - 2 * p.PageLeft)
> Label9.Text = "Horizontal resolution=" + p.HorizontalResolution.ToString
> Label10.Text = "Vertical Resolution=" + p.VerticalResolution.ToString
> Label11.Text = "Left=" + p.Left.ToString
> ```

<div id="printersetup.maximumhorizontalresolution">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.MaximumHorizontalResolution

**MaximumHorizontalResolution** As `Integer</api/data_types/integer>`

> Set to request the maximum horizontal resolution for the printer to use.
>
> You can change it to the maximum printer resolution you're prepared to handle or -1 for the highest possible resolution of the output device. After calling `ShowPageSetupDialog<printersetup.showpagesetupdialog>`, `OpenPrinter<printersetup.openprinter>`, or `ShowPrinterDialog<printersetup.showprinterdialog>`, the `HorizontalResolution<printersetup.horizontalresolution>` property will automatically be set to the highest resolution supported by the printer driver, within your specified constraints, although this may be less than what you have specified. Printing occurs at `HorizontalResolution<printersetup.horizontalresolution>`, so you should always check and use that value after setting this value.
>
> This example sets the MaximumHorizontalResolution and `MaximumVerticalResolution<printersetup.maximumverticalresolution>` properties.
>
> ``` xojo
> Var settings As String
> Var p As New PrinterSetup
>
> If p.ShowPageSetupDialog Then
>   settings = p.ConfigurationData
> End If
> p.MaximumHorizontalResolution = 1200
> p.MaximumVerticalResolution = 1200
> ```

<div id="printersetup.maximumverticalresolution">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.MaximumVerticalResolution

**MaximumVerticalResolution** As `Integer</api/data_types/integer>`

> Set to the maximum vertical resolution at which you wish to print. The default value is 72.
>
> You can change it to the maximum printer resolution you're prepared to handle or -1 for the highest possible resolution of the output device. After calling `ShowPageSetupDialog<printersetup.showpagesetupdialog>`, `OpenPrinter<printersetup.openprinter>`, or `ShowPrinterDialog<printersetup.showprinterdialog>`, the `VerticalResolution<printersetup.verticalresolution>` property will automatically be set to the highest resolution supported by the printer driver, within your specified constraints, although this may be less than what you have specified. Printing occurs at `VerticalResolution<printersetup.verticalresolution>`, so you should always check and use that value after setting this value.
>
> This example sets the MaximumVerticalResolution and `MaximumHorizontalResolution<printersetup.maximumhorizontalresolution>` properties.
>
> ``` xojo
> Var settings As String
> Var p As New PrinterSetup
>
> If p.ShowPageSetupDialog Then
>   settings = p.ConfigurationData
> End If
> p.MaximumHorizontalResolution = 1200
> p.MaximumVerticalResolution = 1200
> ```

<div id="printersetup.pageheight">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.PageHeight

**PageHeight** As `Integer</api/data_types/integer>`

> The height of the page in pixels.
>
> This property is read-only.
>
> This example displays the Page Setup box and then displays the page size, printable area, and margins in Label 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.
>
> ``` xojo
> Var settings As String
> Var p As New PrinterSetup
>
> If p.ShowPageSetupDialog Then
>   settings = p.Settings
> End If
>
> Label1.Text = "PageLeft=" + p.PageLeft.ToString
> Label2.Text = "PageTop=" + p.PageTop.ToString
> Label3.Text = "PageHeight=" + p.PageHeight.ToString
> Label4.Text = "PageWidth=" + p.PageWidth.ToString
> Label5.Text = "Height=" + p.Height.ToString
> Label6.Text = "Width=" + p.Width.ToString
> Label7.Text = "Computed height=" + Str(p.Height - 2 * p.PageTop)
> Label8.Text = "Computed width=" + Str(p.Width - 2 * p.PageLeft)
> Label9.Text = "Horizontal resolution=" + p.HorizontalResolution.ToString
> Label10.Text = "Vertical Resolution=" + p.VerticalResolution.ToString
> ```

<div id="printersetup.pageleft">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.PageLeft

**PageLeft** As `Integer</api/data_types/integer>`

> The offset distance (in pixels) from the left margin of the printable area to the left edge of the physical page, i.e., the left margin.
>
> This property is read-only.
>
> This example displays the Page Setup box and then displays the page size, printable area, and margins in Label 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.
>
> ``` xojo
> Var settings As String
> Var p As New PrinterSetup
>
> If p.ShowPageSetupDialog Then
>   settings = p.Settings
> End If
>
> Label1.Text = "PageLeft=" + p.PageLeft.ToString
> Label2.Text = "PageTop=" + p.PageTop.ToString
> Label3.Text = "PageHeight=" + p.PageHeight.ToString
> Label4.Text = "PageWidth=" + p.PageWidth.ToString
> Label5.Text = "Height=" + p.Height.ToString
> Label6.Text = "Width=" + p.Width.ToString
> Label7.Text = "Computed height=" + Str(p.Height - 2 * p.PageTop)
> Label8.Text = "Computed width=" + Str(p.Width - 2 * p.PageLeft)
> Label9.Text = "Horizontal resolution=" + p.HorizontalResolution.ToString
> Label10.Text = "Vertical Resolution=" + p.VerticalResolution.ToString
> ```

<div id="printersetup.pagetop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.PageTop

**PageTop** As `Integer</api/data_types/integer>`

> The offset distance (in pixels) from the top margin of the printable area to the top edge of the physical page, i.e., the top margin.
>
> This property is read-only.
>
> This example displays the Page Setup box and then displays the page size, printable area, and margins in Label 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.
>
> ``` xojo
> Var settings As String
> Var p As New PrinterSetup
>
> If p.ShowPageSetupDialog Then
>   settings = p.Settings
> End If
>
> Label1.Text = "PageLeft=" + p.PageLeft.ToString
> Label2.Text = "PageTop=" + p.PageTop.ToString
> Label3.Text = "PageHeight=" + p.PageHeight.ToString
> Label4.Text = "PageWidth=" + p.PageWidth.ToString
> Label5.Text = "Height=" + p.Height.ToString
> Label6.Text = "Width=" + p.Width.ToString
> Label7.Text = "Computed height=" + Str(p.Height - 2 * p.PageTop)
> Label8.Text = "Computed width=" + Str(p.Width - 2 * p.PageLeft)
> Label9.Text = "Horizontal resolution=" + p.HorizontalResolution.ToString
> Label10.Text = "Vertical Resolution=" + p.VerticalResolution.ToString
> ```

<div id="printersetup.pagewidth">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.PageWidth

**PageWidth** As `Integer</api/data_types/integer>`

> The width of the page in pixels.
>
> This property is read-only.
>
> This example displays the Page Setup box and then displays the page size, printable area, and margins in Label 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.
>
> ``` xojo
> Var settings As String
> Var p As New PrinterSetup
>
> If p.ShowPageSetupDialog Then
>   settings = p.Settings
> End If
>
> Label1.Text = "PageLeft=" + p.PageLeft.ToString
> Label2.Text = "PageTop=" + p.PageTop.ToString
> Label3.Text = "PageHeight=" + p.PageHeight.ToString
> Label4.Text = "PageWidth=" + p.PageWidth.ToString
> Label5.Text = "Height=" + p.Height.ToString
> Label6.Text = "Width=" + p.Width.ToString
> Label7.Text = "Computed height=" + Str(p.Height - 2 * p.PageTop)
> Label8.Text = "Computed width=" + Str(p.Width - 2 * p.PageLeft)
> Label9.Text = "Horizontal resolution=" + p.HorizontalResolution.ToString
> Label10.Text = "Vertical Resolution=" + p.VerticalResolution.ToString
> ```

<div id="printersetup.settings">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.Settings

**Settings** As `String</api/data_types/string>`

> A value that represents all of the other properties.
>
> When the user clicks OK in the Page Setup dialog box, this value will be populated. You can then store this value to store the user's Page Setup settings. Assigning one of these stored values to this property will then update all of the other properties restoring the page setup settings.
>
> This example displays the Page Setup dialog box and then stores the settings the user chose in a variable:
>
> ``` xojo
> Var s As String
> Var pageSetup As New PrinterSetup
>
> If pageSetup.ShowPageSetupDialog Then
>   s = pageSetup.Settings
> End If
> ```
>
> This example restores the page setup settings stored in a variable (s) and then displays the Page Setup dialog box with those settings:
>
> ``` xojo
> Var pageSetup As New PrinterSetup
>
> pageSetup.Settings = s
>
> If pageSetup.ShowPageSetupDialog Then
>   s = pageSetup.Settings
> End If
> ```

<div id="printersetup.top">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.Top

**Top** As `Integer</api/data_types/integer>`

> The top origin of the printable area. This should always be zero.
>
> This property is read-only.
>
> This example displays the Page Setup box and then displays the page size, printable area, and margins in Label 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.
>
> ``` xojo
> Var settings As String
> Var p As New PrinterSetup
>
> If p.ShowPageSetupDialog Then
>   settings = p.Settings
> End If
>
> Label1.Text = "PageLeft=" + p.PageLeft.ToString
> Label2.Text = "PageTop=" + p.PageTop.ToString
> Label3.Text = "PageHeight=" + p.PageHeight.ToString
> Label4.Text = "PageWidth=" + p.PageWidth.ToString
> Label5.Text = "Height=" + p.Height.ToString
> Label6.Text = "Width=" + p.Width.ToString
> Label7.Text = "Computed height=" + Str(p.Height - 2 * p.PageTop)
> Label8.Text = "Computed width=" + Str(p.Width - 2 * p.PageLeft)
> Label9.Text = "Horizontal resolution=" + p.HorizontalResolution.ToString
> Label10.Text = "Vertical Resolution=" + p.VerticalResolution.ToString
> ```

<div id="printersetup.verticalresolution">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.VerticalResolution

**VerticalResolution** As `Integer</api/data_types/integer>`

> The vertical resolution in dots per inch of the output device (usually a printer).
>
> This property is read-only.
>
> This example displays the Page Setup box and then displays the page size, printable area, and margins in Label 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.
>
> ``` xojo
> Var settings As String
> Var p As New PrinterSetup
>
> If p.ShowPageSetupDialog Then
>   settings = p.Settings
> End If
>
> Label1.Text = "PageLeft=" + p.PageLeft.ToString
> Label2.Text = "PageTop=" + p.PageTop.ToString
> Label3.Text = "PageHeight=" + p.PageHeight.ToString
> Label4.Text = "PageWidth=" + p.PageWidth.ToString
> Label5.Text = "Height=" + p.Height.ToString
> Label6.Text = "Width=" + p.Width.ToString
> Label7.Text = "Computed height=" + Str(p.Height - 2 * p.PageTop)
> Label8.Text = "Computed width=" + Str(p.Width - 2 * p.PageLeft)
> Label9.Text = "Horizontal resolution=" + p.HorizontalResolution.ToString
> Label10.Text = "Vertical Resolution=" + p.VerticalResolution.ToString
> ```

<div id="printersetup.width">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.Width

**Width** As `Integer</api/data_types/integer>`

> The width of the printable area on the page in pixels. The width is the PageWidth minus the margins.
>
> This property is read-only.
>
> This example displays the Page Setup box and then displays the page size, printable area, and margins in Label 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.
>
> ``` xojo
> Var settings As String
> Var p As New PrinterSetup
>
> If p.ShowPageSetupDialog Then
>   settings = p.Settings
> End If
>
> Label1.Text = "PageLeft=" + p.PageLeft.ToString
> Label2.Text = "PageTop=" + p.PageTop.ToString
> Label3.Text = "PageHeight=" + p.PageHeight.ToString
> Label4.Text = "PageWidth=" + p.PageWidth.ToString
> Label5.Text = "Height=" + p.Height.ToString
> Label6.Text = "Width=" + p.Width.ToString
> Label7.Text = "Computed height=" + Str(p.Height - 2 * p.PageTop)
> Label8.Text = "Computed width=" + Str(p.Width - 2 * p.PageLeft)
> Label9.Text = "Horizontal resolution=" + p.HorizontalResolution.ToString
> Label10.Text = "Vertical Resolution=" + p.VerticalResolution.ToString
> ```

## Method descriptions

<div id="printersetup.openprinter">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.OpenPrinter

**OpenPrinter**(setup As PrinterSetup) As `Graphics</api/graphics/graphics>`

> The OpenPrinter function returns a `Graphics</api/graphics/graphics>` object. The various drawing routines can then be used to draw into the `Graphics</api/graphics/graphics>` object and will be sent to the printer for printing.
>
> Although the pageSetup parameter is optional, in order to get the correct horizontal and vertical resolutions for drawing and positioning you will need to provide a <span class="title-ref">PrinterSetup</span>. You can do this without prompting the user with a dialog like this:
>
> ``` xojo
> Var p As New PrinterSetup
> Var g As Graphics = PrinterSetup.OpenPrinter(p)
> Var horizontalDPI As Integer = p.HorizontalResolution
> Var verticalDPI As Integer = p.VerticalResolution
> ```
>
> This code prints "Hello World" to the currently selected printer:
>
> ``` xojo
> Var p As New PrinterSetup
> Var g As Graphics = PrinterSetup.OpenPrinter(p)
>
> If g <> Nil Then
>   ' Draw text 1 inch across and 1 inch down
>   g.DrawText("Hello World", p.HorizontalResolution, p.VerticalResolution)
> End If
> ```
>
> This code uses the Page Setup properties for the printer chosen by the user by the PageSetup dialog:
>
> ``` xojo
> Var ps As New PrinterSetup
>
> If ps.ShowPageSetupDialog Then
>
>   Var g As Graphics = PrinterSetup.OpenPrinter(ps)
>
>   If g <> Nil Then
>     ' Draw text 1 inch across and 1 inch down
>     g.DrawText("Hello World", ps.HorizontalResolution, ps.VerticalResolution)
>   End If
>
> End If
> ```

<div id="printersetup.showpagesetupdialog">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.ShowPageSetupDialog

**ShowPageSetupDialog**(`Optional</api/language/optional>` parentWindow As `DesktopWindow</api/user_interface/desktop/desktopwindow>`) As `Boolean</api/data_types/boolean>`

> Displays the standard Page Setup dialog box.
>
> If the Settings property has been populated before this method is called, the Page Setup dialog box will reflect the settings stored in the Settings property. After the user clicks the OK button to close the Page Setup dialog box, all of the <span class="title-ref">PrinterSetup</span> properties will be updated to reflect the settings the user chose.
>
> On a macOS, PageSetupDialog takes an optional parameter, *parentWindow*. If specified, the Page Setup dialog will appear as a sheet connected to that window.
>
> Returns a `Boolean</api/data_types/boolean>`. This function returns `True</api/language/true>` if the User clicks OK and `False</api/language/false>` if the user clicks Cancel.
>
> This example displays the Page Setup dialog box and then stores the settings the user chose in a variable:
>
> ``` xojo
> Var printerSettings As String
> Var printer As New PrinterSetup
>
> If printer.ShowPageSetupDialog Then
>   printerSettings = printer.Settings
> End If
> ```

<div id="printersetup.showprinterdialog">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PrinterSetup.ShowPrinterDialog

**ShowPrinterDialog**(`Optional</api/language/optional>` parentWindow As `DesktopWindow</api/user_interface/desktop/desktopwindow>`) As `Graphics</api/graphics/graphics>`

> Displays the standard Print dialog box and returns a `Graphics</api/graphics/graphics>` object in order to print to the currently selected printer.
>
> The ShowPrinterDialog function returns a `Graphics</api/graphics/graphics>` object. The various drawing routines can then be used to draw into the `Graphics</api/graphics/graphics>` object and will be sent to the printer for printing. You can get the values in the Copies, From and To fields of the Print dialog box using the Copies, FirstPage and LastPage properties of the `Graphics</api/graphics/graphics>` object returned by the ShowPrinterDialog function.
>
> If the user clicks the Cancel button, the ShowPrinterDialog function returns `Nil</api/language/nil>`.
>
> Although the pageSetup parameter is optional, in order to get the correct horizontal and vertical resolutions for drawing and positioning you will need to provide a <span class="title-ref">PrinterSetup</span>. You can do this without prompting the user with a dialog like this:
>
> ``` xojo
> Var ps As New PrinterSetup
> Var g As Graphics = ps.ShowPrinterDialog(MyWindow)
> Var horizontalDPI As Integer = ps.HorizontalResolution
> Var verticalDPI As Integer = ps.VerticalResolution
> ```
>
> This example prints "Hello World" to the currently selected printer.
>
> ``` xojo
> Var ps As New PrinterSetup
> Var g As Graphics = ps.ShowPrinterDialog
>
> If g <> Nil Then
>   ' Draw text 1 inch across and 1 inch down
>   g.DrawText("Hello World", ps.HorizontalResolution, ps.VerticalResolution)
> End If
> ```
>
> This example uses the Page Setup properties for the printer chosen by the user by the PageSetup dialog:
>
> ``` xojo
> Var ps As New PrinterSetup
>
> If ps.ShowPageSetupDialog Then
>
>   Var g As Graphics = ps.ShowPrinterDialog
>
>   If g <> Nil Then
>     ' Draw text 1 inch across and 1 inch down
>     g.DrawText("Hello World", ps.HorizontalResolution, ps.VerticalResolution)
>   End If
>
> End If
> ```
>
> This example checks if the Windows printer supports alpha blending:
>
> ``` xojo
> Const SHADEBLENDCAPS = 120
> Const SB_NONE = 0
> Const SB_CONST_ALPHA = 1
> Const SB_PIXEL_ALPHA = 2
> Const SB_PREMULT_ALPHA = 4
> Const SB_GRAD_RECT = &h10
> Const SB_GRAD_TRI = &h20
>
> Var ps As New PrinterSetup
> Var g As Graphics = ps.ShowPrinterDialog
> Var hdc As Ptr = g.Handle(Graphics.HandleTypes.HDC)
>
> Declare Function GetDeviceCaps Lib "gdi32" (hdc As Ptr, index As Int32) As Int32
>
> If GetDeviceCaps(hdc, SHADEBLENDCAPS) = SB_NONE Then
>   MessageBox("This Printer does not support alpha blending.")
> Else
>   MessageBox("Yay! This Printer supports alpha blending.")
> End If
> ```

## Notes

The printer reports back a virtual drawing surface that has the resolution supplied in the `HorizontalResolution<printersetup.horizontalresolution>` and `VerticalResolution<printersetup.verticalresolution>` properties. This varies by OS platform. Actual printing resolution is determined by the printer based on guidance provided by you using the `MaximumHorizontalResolution<printersetup.maximumhorizontalresolution>` and `MaximumVerticalResolution<printersetup.maximumverticalresolution>` properties.

When drawing to the Graphic object returned by `OpenPrinter<printersetup.openprinter>`, you should always use the `HorizontalResolution<printersetup.horizontalresolution>` and `VerticalResolution<printersetup.verticalresolution>` properties to ensure correct sizing. This allows your print output to draw correctly when the printer draws at its native resolution.

Passing a <span class="title-ref">PrinterSetup</span> object to the `OpenPrinter<printersetup.openprinter>` or `ShowPrinterDialog<printersetup.showprinterdialog>` functions will cause the printer to utilize those <span class="title-ref">PrinterSetup</span> 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%.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### MaximumHorizontalResolution and MaximumVerticalResolution

These tell the printer the maximum resolutions you would like to use. Changing these does not mean the printer will use the resolutions you specify. You still have to use the `HorizontalResolution<printersetup.horizontalresolution>` and `VerticalResolution<printersetup.verticalresolution>` properties to get the resolution to use for drawing.

## Sample code

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

``` xojo
Var s As String
Var pageSetup As New PrinterSetup

If pageSetup.ShowPageSetupDialog Then
  s = pageSetup.Settings
End If
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

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

``` xojo
Var pageSetup As New PrinterSetup

pageSetup.Settings = s

If pageSetup.ShowPageSetupDialog Then
  s = pageSetup.Settings
End If
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This code displays the Page Setup dialog box and then passes the settings the user chose to the `ShowPrinterDialog<printersetup.showprinterdialog>` function. It then prints a sample string:

``` xojo
Var p As New PrinterSetup

If p.ShowPageSetupDialog Then

  Var g As Graphics = p.ShowPrinterDialog

  If g <> Nil Then
    g.DrawText("Hello World", 50, 50)
  End If

End If
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This code displays the Page Setup box and then displays the page size, printable area, and margins in `Label</api/user_interface/desktop/desktoplabel>` 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.

``` xojo
Var settings As String
Var p As New PrinterSetup

If p.ShowPageSetupDialog Then
  settings = p.Settings
End If

Label1.Text = "PageLeft=" + p.PageLeft.ToString
Label2.Text = "PageTop=" + p.PageTop.ToString
Label3.Text = "PageHeight=" + p.PageHeight.ToString
Label4.Text = "PageWidth=" + p.PageWidth.ToString
Label5.Text = "Height=" + p.Height.ToString
Label6.Text = "Width=" + p.Width.ToString
Label7.Text = "Computed height=" + Str(p.Height - 2 * p.PageTop)
Label8.Text = "Computed width=" + Str(p.Width - 2 * p.PageLeft)
```

## Compatibility

|                       |         |
|-----------------------|---------|
| **Project Types**     | Desktop |
| **Operating Systems** | All     |

<div class="seealso">

Object parent class; `Graphics</api/graphics/graphics>`, `StyledTextPrinter</api/printing/styledtextprinter>` classes; `OpenPrinter<printersetup.openprinter>`, `ShowPrinterDialog<printersetup.showprinterdialog>` functions.

</div>
