PageMediaSize.Width 속성

정의

페이지 너비를 가져옵니다.

public:
 property Nullable<double> Width { Nullable<double> get(); };
public double? Width { get; }
member this.Width : Nullable<double>
Public ReadOnly Property Width As Nullable(Of Double)

속성 값

페이지 너비를 픽셀(1/96인치)로 나타내는 Double입니다.

예제

다음 예제에서는이 클래스를 사용 하 여 인쇄 되는 페이지의 여백 내에 맞게 시각적 요소를 확장 하는 방법을 보여 줍니다.

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

적용 대상