Export (0) Print
Expand All

PageMediaSize Class

Describes the page size for paper or other media.

System.Object
  System.Printing.PageMediaSize

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

public sealed class PageMediaSize

The PageMediaSize type exposes the following members.

  NameDescription
Public methodPageMediaSize(PageMediaSizeName)Initializes a new instance of the PageMediaSize class by using the specified PageMediaSizeName.
Public methodPageMediaSize(Double, Double)Initializes a new instance of the PageMediaSize class by using the width and height.
Public methodPageMediaSize(PageMediaSizeName, Double, Double)Initializes a new instance of the PageMediaSize class by using the specified PageMediaSizeName and the width and height.
Top

  NameDescription
Public propertyHeightGets the page height.
Public propertyPageMediaSizeNameGets the name of the page size for paper or other media.
Public propertyWidthGets the page width.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodToStringDisplays the page size for paper or other media. (Overrides Object.ToString().)
Top

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.

Caution noteCaution

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 Visual PerformTransform(Visual v, PrintQueue pq)
{
    ContainerVisual root = new ContainerVisual();
    const double inch = 96;

    // Set the margins. 
    double xMargin = 1.25 * inch;
    double yMargin = 1 * inch;

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

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

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

    return root;
}// end:PerformTransform()

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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