PageMediaSize Class

Describes the page size for paper or other media.

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

public sealed class PageMediaSize
public final class PageMediaSize
public final class PageMediaSize
You cannot use this managed class in XAML.

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.

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. For the full sample, see Printing an XPS Document.

/// <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.Transform = new MatrixTransform(xScale, 0, 0, yScale, xMargin, yMargin);

    return root;
}// end:PerformTransform()


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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0