1

如何调整System.Windows.Controls.PrintDialog.PrintableAreaHeight&System.Windows.Controls.PrintDialog.PrintableAreaWidth因为它们是只读的?

4

2 回答 2

1

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(...);
}
于 2014-12-18T06:09:05.653 回答
1

在 WPF 中,您可以使用System.Windows.Controls.PrintDialog. 这个类有很多属性可以改变页面的外观。

在 Windows 窗体中,您可以使用YourPrintDialog.PrinterSettings.DefaultPageSettings.PaperSize. 这是 MSDN 的链接:PrinterSettings.PaperSizes 属性

于 2014-09-17T07:39:18.450 回答