没有保证金打印

Fri*_*ale 4 printing wpf

我试图打印4英寸高,3英尺宽的WPF控件.

ScaleTransform在控制器(a Canvas)上使用了相应的比例尺; 但是,当我打印到打印机时,图像的一部分被切断(顶部和左边缘).

根据这个帖子:

出现此问题的原因是打印机在纸张边缘周围提供了未打印的边距,但该PrintDialog.PrintVisual方法打算打印到纸张边缘.因此,位于纸张边缘周围未打印边缘的区域将被剪裁.

线程没有提到如何检索边距或如何强制打印机忽略这些边距.如何获取这些值,以便我可以使用WPF打印而不剪切?

use*_*116 5

你需要的信息从结合PrintDocumentImageableAreaMeasureArrange成员对您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
}
Run Code Online (Sandbox Code Playgroud)