如何调整System.Windows.Controls.PrintDialog.PrintableAreaHeight
&System.Windows.Controls.PrintDialog.PrintableAreaWidth
因为它们是只读的?
2 回答
PrintableAreaHeight
and PrintableAreaWidth
is calculated based on the PrintDialog.PrintTicket
that is used. In other words they can't be adjusted because the printer that is printing the document specifies what values to use. If you really want to change the print area, which can cause the printer to print ink on it rollers if the size is larger than what can actually be printed, you could do:
var pd = new PrintDialog();
if(pd.ShowDialog() == true)
{
pd.PrintTicket.PageMediaSize = new PageMediaSize(newWidth, newHeight);
pd.PrintDocument(...);
}
在 WPF 中,您可以使用System.Windows.Controls.PrintDialog
. 这个类有很多属性可以改变页面的外观。
在 Windows 窗体中,您可以使用YourPrintDialog.PrinterSettings.DefaultPageSettings.PaperSize
. 这是 MSDN 的链接:PrinterSettings.PaperSizes 属性