我正在使用 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 英寸)时,对象会从右侧被剪裁,因为它会在纸张左侧生成边距。谁能告诉我如何避免在纸上出现此页边距并全长打印对象?
谢谢