PageMediaSize.Height 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取页面高度。
public:
property Nullable<double> Height { Nullable<double> get(); };
public double? Height { get; }
member this.Height : Nullable<double>
Public ReadOnly Property Height As Nullable(Of Double)
属性值
一个 Double,表示以像素为单位的页面高度(1/96 英寸)。
示例
以下示例演示如何使用此类缩放可视元素,使其适合打印纸张的边距。
/// <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()