你需要的信息从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