你需要的信息從PrintDocumentImageableArea
與Measure
和Arrange
成員的UIElement
結合:
// I could not find another way to change the margins other than the dialog
var result = printDialog.ShowDialog();
if (result.HasValue && result.Value)
{
var queue = printDialog.PrintQueue;
// Contains extents and offsets
var area = queue.GetPrintCapabilities(printDialog.PrintTicket)
.PageImageableArea;
// scale = area.ExtentWidth and area.ExtentHeight and your UIElement's bounds
// margin = area.OriginWidth and area.OriginHeight
// 1. Use the scale in your ScaleTransform
// 2. Use the margin and extent information to Measure and Arrange
// 3. Print the visual
}
謝謝你,現在我想它。 – Frinavale 2012-03-13 13:06:07
非常感謝您的幫助。有效。我必須添加邊距(乘以2來獲得左側,右側,頂部和底部)到我試圖打印的項目的大小。我在Measure和Arrange方法中使用了這個尺寸(在頂部開始編配方法,左邊距)。 – Frinavale 2012-03-13 14:21:55