• Artem
  • Newbie Topic Starter
Is it possible to programmatically change the page setting without causing a PageSetup dialogue?

When we print in .NET using the standard features, we use an object of the PrintDocument class. To adjust the page settings, we use its DefaultPageSettings property.

In our PrintManager, the PrintDocument is provided by the Document property. For example, if you need to print in landscape and have the left/right margins of 1 inch, top/bottom ones of 0.5 inch, the code will look like this:

iGPrintManager1.Document.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(100, 100, 50, 50);
iGPrintManager1.Document.DefaultPageSettings.Landscape = true;

/printer margins are measured in hundredths of an inch/.

You can also control other printer settings thru the PrinterSettings property. For instance, to print only the first two pages, use this code snippet:

iGPrintManager1.Document.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.SomePages;
iGPrintManager1.Document.PrinterSettings.FromPage = 1;
iGPrintManager1.Document.PrinterSettings.ToPage = 2;
iGPrintManager1.Document.PrinterSettings.MinimumPage = 1;
iGPrintManager1.Document.PrinterSettings.MaximumPage = 2;