1

How to adjust System.Windows.Controls.PrintDialog.PrintableAreaHeight & System.Windows.Controls.PrintDialog.PrintableAreaWidth since they are read only?

tezzo
  • 10,858
  • 1
  • 25
  • 48

2 Answers2

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(...);
}
Kcvin
  • 5,073
  • 2
  • 32
  • 54
1

In WPF you can use the PrintTicket Class of System.Windows.Controls.PrintDialog. This class has a lot of properties to change the aspect of the page.

In Windows Forms you can use YourPrintDialog.PrinterSettings.DefaultPageSettings.PaperSize. Here is a link to MSDN: PrinterSettings.PaperSizes Property

tezzo
  • 10,858
  • 1
  • 25
  • 48
  • I can't get this to work as the printdialog you refered to me is part of System.Windows.Forms I am actually working with WPF – Jervin Khoo Sep 18 '14 at 06:55