PrintTicket.PageMediaSize PrintTicket.PageMediaSize PrintTicket.PageMediaSize PrintTicket.PageMediaSize Property

Definición

Obtiene o establece el tamaño de página del papel (u otro medio) que utiliza una impresora para un trabajo de impresión.Gets or sets the page size for the paper (or other media) that a printer uses for a print job.

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

Valor de propiedad

Un objeto PageMediaSize que representa el tamaño de página mediante un nombre, las dimensiones o ambos.A PageMediaSize object that represents the page size by using a name, dimensions, or both.

Excepciones

El código de llamada ha intentado establecer la propiedad con un objeto PageMediaSize que tiene por lo menos una propiedad null.Calling code has attempted to set the property with a PageMediaSize object that has at least one null property.

o bien-or- El código de llamada ha intentado establecer la propiedad con un objeto PageMediaSize cuya propiedad PageMediaSizeName está establecida en un valor que no está en la enumeración PageMediaSizeName.Calling code has attempted to set the property with a PageMediaSize object whose PageMediaSizeName property is set to a value that is not in the PageMediaSizeName enumeration.

O bien-or- El código de llamada ha intentado establecer la propiedad con un objeto PageMediaSize cuya propiedad Width o Height está establecida en un valor menor que 1.Calling code has attempted to set the property with a PageMediaSize object whose Width or Height property is set to a value less than 1.

Ejemplos

En el ejemplo siguiente se muestra cómo utilizar esta propiedad para escalar un elemento visual para que quepa dentro de los márgenes del papel en el que se va a imprimir.The following example shows how to use this property 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()
''' <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()

Comentarios

Esta propiedad corresponde a la palabra clave del PageMediaSize esquema de impresión.This property corresponds to the Print Schema's PageMediaSize keyword.

Puede comprobar las opciones que admite la impresora mediante la PageMediaSizeCapability propiedad.You can test for the options that the printer supports by using the PageMediaSizeCapability property.

Se aplica a