PageMediaSize PageMediaSize PageMediaSize PageMediaSize Class

Definición

Describe el tamaño de página del papel u otro soporte.Describes the page size for paper or other media.

public ref class PageMediaSize sealed
public sealed class PageMediaSize
type PageMediaSize = class
Public NotInheritable Class PageMediaSize
Herencia
PageMediaSizePageMediaSizePageMediaSizePageMediaSize

Ejemplos

En el ejemplo siguiente se muestra cómo utilizar esta clase para escalar un elemento visual de forma que quepa dentro de los márgenes del papel en el que se va a imprimir.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()
''' <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

Para una clase que incluye la misma información sobre el tamaño del medio PageMediaSize que y también incluye información sobre el área de impresión de la página, PrintDocumentImageableAreavea.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.

Precaución

Las clases del System.Printing espacio de nombres no se admiten para su uso en un servicio de Windows o en una aplicación o servicio ASP.net.Classes within the System.Printing namespace are not supported for use within a Windows service or ASP.NET application or service. Intentar usar estas clases desde dentro de uno de estos tipos de aplicación puede producir problemas inesperados, como el rendimiento del servicio reducido y las excepciones en tiempo de ejecución.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.

Si desea imprimir desde una aplicación Windows Forms, vea el System.Drawing.Printing espacio de nombres.If you want to print from a Windows Forms application, see the System.Drawing.Printing namespace.

Constructores

PageMediaSize(Double, Double) PageMediaSize(Double, Double) PageMediaSize(Double, Double) PageMediaSize(Double, Double)

Inicializa una nueva instancia de la clase PageMediaSize utilizando el ancho y alto.Initializes a new instance of the PageMediaSize class by using the width and height.

PageMediaSize(PageMediaSizeName) PageMediaSize(PageMediaSizeName) PageMediaSize(PageMediaSizeName) PageMediaSize(PageMediaSizeName)

Inicializa una nueva instancia de la clase PageMediaSize utilizando el objeto PageMediaSizeName especificado.Initializes a new instance of the PageMediaSize class by using the specified PageMediaSizeName.

PageMediaSize(PageMediaSizeName, Double, Double) PageMediaSize(PageMediaSizeName, Double, Double) PageMediaSize(PageMediaSizeName, Double, Double) PageMediaSize(PageMediaSizeName, Double, Double)

Inicializa una nueva instancia de la clase PageMediaSize utilizando el PageMediaSizeName especificado y el ancho y alto.Initializes a new instance of the PageMediaSize class by using the specified PageMediaSizeName and the width and height.

Propiedades

Height Height Height Height

Obtiene el alto de página.Gets the page height.

PageMediaSizeName PageMediaSizeName PageMediaSizeName PageMediaSizeName

Obtiene el nombre del tamaño de página del papel u otro soporte.Gets the name of the page size for paper or other media.

Width Width Width Width

Obtiene el ancho de página.Gets the page width.

Métodos

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Muestra el tamaño de página del papel u otro soporte.Displays the page size for paper or other media.

Se aplica a