PageMediaSize Class

 

Describes the page size for paper or other media.

Namespace:   System.Printing
Assembly:  ReachFramework (in ReachFramework.dll)

System.Object
  System.Printing.PageMediaSize

Public NotInheritable Class PageMediaSize

NameDescription
System_CAPS_pubmethodPageMediaSize(Double, Double)

Initializes a new instance of the PageMediaSize class by using the width and height.

System_CAPS_pubmethodPageMediaSize(PageMediaSizeName)

Initializes a new instance of the PageMediaSize class by using the specified PageMediaSizeName.

System_CAPS_pubmethodPageMediaSize(PageMediaSizeName, Double, Double)

Initializes a new instance of the PageMediaSize class by using the specified PageMediaSizeName and the width and height.

NameDescription
System_CAPS_pubpropertyHeight

Gets the page height.

System_CAPS_pubpropertyPageMediaSizeName

Gets the name of the page size for paper or other media.

System_CAPS_pubpropertyWidth

Gets the page width.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodToString()

Displays the page size for paper or other media.(Overrides Object.ToString().)

For a class that includes the same information about the media size as PageMediaSize and also includes information about the imageable area of the page, see PrintDocumentImageableArea.

System_CAPS_cautionCaution

Classes within the System.Printing namespace are not supported for use within a Windows service or ASP.NET application or service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.

If you want to print from a Windows Forms application, see the System.Drawing.Printing namespace.

The following example shows how to use this class to scale a visual element to fit within the margins of the paper on which it is to print.

''' <summary>
'''   Returns a scaled copy of a given visual transformed to
'''   fit for printing to a specified print queue.</summary>
''' <param name="v">
'''   The visual to be printed.</param>
''' <param name="pq">
'''   The print queue to be output to.</param>
''' <returns>
'''   The root element of the transformed visual.</returns>
Private Function PerformTransform(ByVal v As Visual, ByVal pq As PrintQueue) As Visual
	Dim root As New ContainerVisual()
	Const inch As Double = 96

	' Set the margins.
	Dim xMargin As Double = 1.25 * inch
	Dim yMargin As Double = 1 * inch

	Dim pt As PrintTicket = pq.UserPrintTicket
	Dim printableWidth As Double = pt.PageMediaSize.Width.Value
	Dim printableHeight As Double = pt.PageMediaSize.Height.Value

	Dim xScale As Double = (printableWidth - xMargin * 2) / printableWidth
	Dim yScale As Double = (printableHeight - yMargin * 2) / printableHeight

	root.Children.Add(v)
	root.Transform = New MatrixTransform(xScale, 0, 0, yScale, xMargin, yMargin)

	Return root
End Function ' end:PerformTransform()

.NET Framework
Available since 3.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: