PrintTicket.PageMediaSize Vlastnost

Definice

Získá nebo nastaví velikost stránky pro papír (nebo jiné médium), které tiskárna používá pro tiskovou úlohu.

public:
 property System::Printing::PageMediaSize ^ PageMediaSize { System::Printing::PageMediaSize ^ get(); void set(System::Printing::PageMediaSize ^ value); };
public System.Printing.PageMediaSize PageMediaSize { get; set; }
member this.PageMediaSize : System.Printing.PageMediaSize with get, set
Public Property PageMediaSize As PageMediaSize

Hodnota vlastnosti

Objekt PageMediaSize , který představuje velikost stránky pomocí názvu, dimenzí nebo obojího.

Výjimky

Volající kód se pokusil nastavit vlastnost s objektem PageMediaSize , který má alespoň jednu null vlastnost.

-nebo-

Volající kód se pokusil nastavit vlastnost s objektem PageMediaSize , jehož PageMediaSizeName vlastnost je nastavena na hodnotu, která není ve výčtu PageMediaSizeName .

-nebo-

Volající kód se pokusil nastavit vlastnost s objektem PageMediaSize , jehož Width vlastnost nebo Height je nastavena na hodnotu menší než 1.

Příklady

Následující příklad ukazuje, jak tuto vlastnost použít ke škálování vizuálního prvku tak, aby se vešel do okrajů papíru, na který se má vytisknout.

/// <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()
''' <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()

Poznámky

Tato vlastnost odpovídá klíčovému slovu Print SchemaPageMediaSize.

Pomocí vlastnosti můžete otestovat možnosti, které tiskárna podporuje PageMediaSizeCapability .

Platí pro