1

我正在使用 WPF PrintVisual 方法来打印对象。在下面检查我的代码。

PrintDialog dialog = new PrintDialog();
System.Printing.PrintCapabilities capabilities = dialog.PrintQueue.GetPrintCapabilities(dialog.PrintTicket);
Double height = dialog.PrintableAreaHeight;
Double width = dialog.PrintableAreaWidth;
myObj.Measure(new Size(width, height));
myObj.Arrange(new Rect(new Point((capabilities.PageImageableArea.OriginWidth), (capabilities.PageImageableArea.OriginHeight)), new Size(width, height)));
dialog.PrintVisual(myObj, "Print in WPF with fit to printing page");

如果我在 xps 中打印它,它工作得很好。但是当我在纸上打印(A4 => 8.5 x 11 英寸)时,对象会从右侧被剪裁,因为它会在纸张左侧生成边距。谁能告诉我如何避免在纸上出现此页边距并全长打印对象?

谢谢

4

1 回答 1

1

您使用的是可打印尺寸,但对于可打印的来源,这是非常dialog.PrintableAreaHeight可疑dialog.PrintableAreaWidthcapabilities.PageImageableArea。这些是不相关的测量;尝试使用

new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight)

myObj.MeasuremyObj.Arrange

于 2013-07-25T01:59:08.507 回答