Difference between revisions of "PrinterSetup"

From Xojo Documentation

m (1 revision)
 
 
(44 intermediate revisions by 8 users not shown)
Line 1: Line 1:
 +
{{ClassBox
 +
| super=Object
 +
| scope=global
 +
}}
 +
{{Description
 +
|text = Used to get and set the page setup settings. }}
  
 +
<dynamicTable id="Properties" class="propertyTable" title="Properties" columns="3">
 +
{{Property | name=Height | type=Integer | platform=all | readonly=yes | description=( Integer)&nbsp;&nbsp;The height of the printable area on the page (in pixels).  }}
 +
{{Property | name=HorizontalResolution | type=Integer | platform=all | readonly=yes | description=( Integer)&nbsp;&nbsp;The horizontal resolution in dots per inch of the output device (usually a printer) }}
 +
{{Property | name=Landscape | type=Boolean | platform=all | newinversion=2007r4 | description=( Boolean)&nbsp;&nbsp;Gets and sets the landscape state of the PrinterSetup object.  }}
 +
{{Property | name=Left | type=Integer | platform=all | readonly=yes | description=( Integer)&nbsp;&nbsp;The left origin of the printable area.  }}
 +
{{Property | name=MaximumHorizontalResolution | type=Integer | platform=all | description=( Integer)&nbsp;&nbsp;Set to the maximum horizontal resolution at which you wish to print }}
 +
{{Property | name=MaximumVerticalResolution | type=Integer |  platform=all | description=( Integer)&nbsp;&nbsp;Set to the maximum vertical resolution at which you wish to print }}
 +
{{Property | name=PageHeight | type=Integer | platform=all | readonly=yes | description=( Integer)&nbsp;&nbsp;The height of the page in pixels. }}
 +
{{Property | name=PageLeft | type=Integer | platform=all | readonly=yes | description=( Integer)&nbsp;&nbsp;The offset distance (in pixels) from the left margin of the printable area to the left edge of the physical page.}}
 +
{{Property | name=PageTop | type=Integer | platform=all | readonly=yes | description=( Integer)&nbsp;&nbsp;The offset distance (in pixels) from the top margin of the printable area to the top edge of the physical page.}}
 +
{{Property | name=PageWidth | type=Integer | platform=all | readonly=yes | description=( Integer)&nbsp;&nbsp;The width of the page in pixels. }}
 +
{{Property | name=Settings | type=String | platform=all | description=( String)&nbsp;&nbsp;A value that represents all of the other properties.  }}
 +
{{Property | name=Top | type=Integer | platform=all | readonly=yes | description=( Integer)&nbsp;&nbsp;The top origin of the printable area. This should always be zero. }}
 +
{{Property | name=VerticalResolution | type=Integer | platform=all | readonly=yes | description=( Integer)&nbsp;&nbsp;The vertical resolution in dots per inch of the output device (usually a printer) }}
 +
{{Property | name=Width | type=Integer | platform=all | readonly=yes | description=( Integer)&nbsp;&nbsp;The width of the printable area on the page in pixels }}
 +
</dynamicTable>
  
=='''Description'''==
+
<dynamicTable id="Methods" class="methodTable" title="Methods" columns="3">
Used to get and set the page setup settings.
+
{{Method | name=ShowPageSetupDialog | params=[window as [[Window]]] | returntype=[[Boolean]] | description=ShowPageSetupDialog(Optional window as Window) As Boolean&#x0A;Displays the standard Page Setup dialog box.&#x0A;ShowPageSetupDialog(Optional window as DesktopWindow) As Boolean&#x0A;Displays the standard Page Setup dialog box.}}
 +
{{Method | name=ShowPrinterDialog | params=[parentWindow as [[Window]]] | description=ShowPrinterDialog(Optional parentWindow as Window) As Boolean&#x0A;Displays the standard Page Setup dialog box.&#x0A;ShowPrinterDialog(Optional parentWindow as DesktopWindow) As Boolean&#x0A;Displays the standard Page Setup dialog box.}}
 +
</dynamicTable>
  
 +
<dynamicTable id="Methods" class="methodTable" title="Shared Methods" columns="3">
 +
{{Method | name=OpenPrinter | params=[setup as [[PrinterSetup]]] | description=OpenPrinter ( setup as PrinterSetup )&#x0A;Returns a Graphics object that can be drawn into which will be sent to the printer for printing.  }}
 +
</dynamicTable>
  
 +
== Notes ==
 +
The printer reports back a virtual drawing surface that has the resolution supplied in the [[PrinterSetup.HorizontalResolution|HorizontalResolution]] and [[PrinterSetup.VerticalResolution|VerticalResolution]] properties. This varies by OS platform. Actual printing resolution is determined by the printer based on guidance provided by you using the [[PrinterSetup.MaximumHorizontalResolution|MaximumHorizontalResolution]] and [[PrinterSetup.MaximumVerticalResolution|MaximumVerticalResolution]] properties.
  
=='''Super Class'''==
+
When drawing to the Graphic object returned by [[PrinterSetup.OpenPrinter|OpenPrinter]], you should always use the [[PrinterSetup.HorizontalResolution|HorizontalResolution]] and [[PrinterSetup.VerticalResolution|VerticalResolution]] properties to ensure correct sizing. This allows your print output to draw correctly when the printer draws at its native resolution.
Object
 
  
=='''Properties'''==
+
Passing a PrinterSetup object to the [[PrinterSetup.OpenPrinter|OpenPrinter]] or [[PrinterSetup.ShowPrinterDialog|ShowPrinterDialog]] 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%.
  
{| cellpadding="8" cellspacing="0" border="1"
+
=== 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 [[PrinterSetup.HorizontalResolution|HorizontalResolution]] and [[PrinterSetup.VerticalResolution|VerticalResolution]] properties to get the resolution to use for drawing.
  
! width=10%  style="background-color:#e0e0e0" | Name
+
== Sample Code ==
 +
This code displays the Page Setup dialog box and then stores the settings the user chose in a variable:
  
! width=15%  style="background-color:#e0e0e0" | Type
+
<rbcode>
 +
Var s As String
 +
Var pageSetup As PrinterSetup
 +
pageSetup = New PrinterSetup
 +
If pageSetup.ShowPageSetupDialog Then
 +
  s = pageSetup.Settings
 +
End If
 +
</rbcode>
  
! width=55%  style="background-color:#e0e0e0" | Description
+
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:
|-
 
|<div style="font-weight:bold; color:red;">Height</div>
 
|[[Integer|Integer]]
 
|The height of the printable area on the page (in pixels).
 
The height is the PageHeight minus the margins.
 
  
|-
+
<rbcode>
|<div style="font-weight:bold; color:red;">HorizontalResolution</div>
+
Var pageSetup As PrinterSetup
|[[Integer|Integer]]
+
pageSetup = New PrinterSetup
|The horizontal resolution in dots per inch of the output device (usually a printer).
+
pageSetup.Settings = s
 +
If pageSetup.ShowPageSetupDialog Then
 +
  s = pageSetup.Settings
 +
End If
 +
</rbcode>
  
|-
+
This code displays the Page Setup dialog box and then passes the settings the user chose to the [[PrinterSetup.ShowPrinterDialog]] function. It then prints a sample string:
|Landscape
 
<div style="font-style:italic; color:green;">Introduced 2007r4</div>
 
|[[Boolean|Boolean]]
 
|Gets and sets the landscape state of the PrinterSetup object.
 
It is [[True|True]] for the landscape orientation; [[False|False]] otherwise. Currently supported on Windows and Mac OS X only.
 
  
|-
+
<rbcode>
|Left
+
Var g As Graphics
 +
Var p As PrinterSetup
 +
p = New PrinterSetup
 +
If p.ShowPageSetupDialog Then
 +
  g = p.ShowPrinterDialog
 +
  If g <> Nil Then
 +
    g.DrawText("Hello World", 50, 50)
 +
  End If
 +
End If
 +
</rbcode>
  
|[[Integer|Integer]]
+
This code 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.
|The left origin of the printable area.  
+
<rbcode>
This should always be zero.
+
Var settings As String
 +
Var p As PrinterSetup
 +
p = New PrinterSetup
 +
If p.PageSetupDialog Then
 +
  settings = p.SetupString
 +
End If
  
|-
+
Label1.Value = "PageLeft=" + p.PageLeft.ToString
|MaxHorizontalResolution
+
Label2.Value = "PageTop=" + p.PageTop.ToString
 +
Label3.Value = "PageHeight=" + p.PageHeight.ToString
 +
Label4.Value = "PageWidth=" + p.PageWidth.ToString
 +
Label5.Value = "Height=" + p.Height.ToString
 +
Label6.Value = "Width=" + p.Width.ToString
 +
Label7.Value = "Computed height=" + Str(p.Height - 2 * p.PageTop)
 +
Label8.Value = "Computed width=" + Str(p.Width - 2 * p.PageLeft)
 +
</rbcode>
  
|[[Integer|Integer]]
+
== See Also ==
|Set to the maximum horizontal resolution at which you wish to print. The default value is 72.
+
[[Graphics]], [[StyledTextPrinter]] classes; [[PrinterSetup.OpenPrinter|OpenPrinter]], [[PrinterSetup.ShowPrinterDialog|ShowPrinterDialog]] functions.
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 PageSetupDialog, OpenPrinter, or OpenPrinterDialog, the HorizontalResolution property will automatically be set to the highest resolution supported by the printer driver, within your specified constraints. Printing will then occur at that resolution. This will not affect existing code.
 
  
|-
+
[[Category:Graphics/Multimedia_Printing]]
|MaxVerticalResolution
+
[[Category:Text_Printing]]
 
+
[[Category:Hardware_Printing]]
|[[Integer|Integer]]
+
[[Category:Desktop]]
|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 PageSetupDialog, OpenPrinter, or OpenPrinterDialog, the VerticalResolution property will automatically be set to the highest resolution supported by the printer driver, within your specified constraints. Printing will then occur at that resolution. This will not affect existing code.
 
 
 
|-
 
|<div style="font-weight:bold; color:red;">PageHeight</div>
 
|[[Integer|Integer]]
 
|The height of the page in pixels.
 
 
 
|-
 
|<div style="font-weight:bold; color:red;">PageLeft</div>
 
|[[Integer|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.
 
 
 
|-
 
|<div style="font-weight:bold; color:red;">PageTop</div>
 
|[[Integer|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.
 
 
 
|-
 
|<div style="font-weight:bold; color:red;">PageWidth</div>
 
|[[Integer|Integer]]
 
|The width of the page in pixels.
 
 
 
|-
 
|SetupString
 
 
 
|[[String|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.
 
 
 
|-
 
|<div style="font-weight:bold; color:red;">Top</div>
 
|[[Integer|Integer]]
 
|The top origin of the printable area. This should always be zero.
 
 
 
|-
 
|<div style="font-weight:bold; color:red;">VerticalResolution</div>
 
|[[Integer|Integer]]
 
|The vertical resolution in dots per inch of the output device (usually a printer).
 
 
 
|-
 
|<div style="font-weight:bold; color:red;">Width</div>
 
|[[Integer|Integer]]
 
|The width of the printable area on the page in pixels. The width is the PageWidth minus the margins.
 
 
 
|-
 
|}
 
 
 
 
 
=='''Methods'''==
 
 
 
{| cellpadding="8" cellspacing="0" border="1"
 
 
 
! width=10%  style="background-color:#e0e0e0" | Name
 
 
 
! width=20%  style="background-color:#e0e0e0" | Parameters
 
 
 
! width=25%  style="background-color:#e0e0e0" | Return Type
 
 
 
! width=55%  style="background-color:#e0e0e0" | Description
 
|-
 
|PageSetupDialog
 
 
 
|[window as [[WindowClass|Window]]]
 
 
 
|[[Boolean|Boolean]]
 
|Displays the standard Page Setup dialog box.
 
If the SetupString property has been populated before this method is called, the Page Setup dialog box will reflect the settings stored in the SetupString property. After the user clicks the OK button to close the Page Setup dialog box, all of the PrinterSetup properties will be updated to reflect the settings the user chose.
 
PageSetupDialog takes an optional parameter, ''window''. If passed, ''window'' is a dialog or sheet window that you wish to use as the Page Setup dialog box instead of the built in dialog. Returns a [[Boolean|Boolean]]. This function returns [[True|True]] if the User clicks OK and [[False|False]] if the user clicks Cancel.
 
 
 
|-
 
|}
 
 
 
 
 
=='''Notes'''==
 
Passing a PrinterSetup object to the [[OpenPrinter|OpenPrinter]] or [[OpenPrinterDialog|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|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 a [[TextArea|TextArea]] 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 and then stores the settings the user chose in a variable:
 
{| cellpadding="8" cellspacing="0" border="1"
 
|<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[Dim|Dim]] settings as [[String|String]]<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[Dim|Dim]] PageSetup as '''PrinterSetup'''<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">PageSetup=[[New|New]] '''PrinterSetup'''<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[If|If]] PageSetup.PageSetupDialog Then
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">&#xA0;settings=PageSetup.SetupString
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">End If
 
<br /></div>
 
 
 
|-
 
|}
 
 
 
This example restores the page setup settings stored in a variable called "settings" and then displays the Page Setup dialog box with those settings:
 
{| cellpadding="8" cellspacing="0" border="1"
 
|<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[Dim|Dim]] PageSetup as '''PrinterSetup'''<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">PageSetup=[[New|New]] '''PrinterSetup'''<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">PageSetup.SetupString=settings
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[If|If]] PageSetup.PageSetupDialog Then
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">&#xA0;settings=PageSetup.SetupString
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">End If
 
<br /></div>
 
 
 
|-
 
|}
 
 
 
This example displays the Page Setup dialog box and then passes the settings the user chose to the [[OpenPrinterDialog|OpenPrinterDialog]] function. It then prints a sample string:
 
{| cellpadding="8" cellspacing="0" border="1"
 
|<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[Dim|Dim]] g as [[Graphics|Graphics]]<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[Dim|Dim]] p as '''PrinterSetup'''<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">p=[[New|New]] '''PrinterSetup'''<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[If|If]] p.PageSetupDialog then
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">&#xA0;g=[[OpenPrinterDialog|OpenPrinterDialog]](p)
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[If|If]] g&lt;&gt; [[Nil|Nil]] then
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">&#xA0;&#xA0;g.DrawString "Hello World", 50,50
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">&#xA0;End if
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">End if
 
<br /></div>
 
 
 
|-
 
|}
 
 
 
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.
 
{| cellpadding="8" cellspacing="0" border="1"
 
|<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[Dim|Dim]] settings as [[String|String]]<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[Dim|Dim]] p as '''PrinterSetup'''<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">p=[[New|New]] '''PrinterSetup'''<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[If|If]] p.PageSetupDialog Then
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">&#xA0;settings=p.SetupString
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">End If
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[StaticText|staticText1]].text="PageLeft="+[[Str|Str]](p.pageLeft)
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[StaticText|staticText2]].text="PageTop="+[[Str|Str]](p.pagetop)
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[StaticText|staticText3]].text="PageHeight="+[[Str|Str]](p.pageheight)
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[StaticText|staticText4]].text="PageWidth="+[[Str|Str]](p.pagewidth)
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[StaticText|staticText5]].text="Height="+[[Str|Str]](p.Height)
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[StaticText|staticText6]].text="Width="+[[Str|Str]](p.width)
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[StaticText|staticText7]].text="Computed height="+[[Str|Str]](p.height-2*p.pagetop)
 
<br /></div>
 
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">[[StaticText|staticText8]].text="Computed width="+[[Str|Str]](p.width-2*p.pageleft)
 
<br /></div>
 
 
 
|-
 
|}
 
 
 
 
 
=='''See Also'''==
 
[[Graphics|Graphics]], [[StyledTextPrinter|StyledTextPrinter]] classes; [[OpenPrinter|OpenPrinter]], [[OpenPrinterDialog|OpenPrinterDialog]] functions.
 
 
 
 
 
[[Category:Classes]]
 
[[Category:Printing]]
 
[[Category:Printing]]
 

Latest revision as of 17:34, 24 January 2022

Class (inherits from Object)

Used to get and set the page setup settings.

Properties
Height fa-lock-32.png MaximumVerticalResolution Settings
HorizontalResolution fa-lock-32.png PageHeight fa-lock-32.png Top fa-lock-32.png
Landscape PageLeft fa-lock-32.png VerticalResolution fa-lock-32.png
Left fa-lock-32.png PageTop fa-lock-32.png Width fa-lock-32.png
MaximumHorizontalResolution PageWidth fa-lock-32.png
Methods
ShowPageSetupDialog ShowPrinterDialog
Shared Methods
OpenPrinter

Notes

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

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

Passing a PrinterSetup object to the OpenPrinter or ShowPrinterDialog 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%.

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 and 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:

Var s As String
Var pageSetup As PrinterSetup
pageSetup = 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:

Var pageSetup As PrinterSetup
pageSetup = 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 PrinterSetup.ShowPrinterDialog function. It then prints a sample string:

Var g As Graphics
Var p As PrinterSetup
p = New PrinterSetup
If p.ShowPageSetupDialog Then
g = 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 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.

Var settings As String
Var p As PrinterSetup
p = New PrinterSetup
If p.PageSetupDialog Then
settings = p.SetupString
End If

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

See Also

Graphics, StyledTextPrinter classes; OpenPrinter, ShowPrinterDialog functions.