Welcome Guest! To enable all features please Login or Register.



Go to last post Go to first unread
#1 Posted : Tuesday, January 10, 2012 1:18:34 PM(UTC)

Rank: Newbie

Groups: Registered
Joined: 1/10/2012(UTC)
Posts: 1

Is it possible to programmatically change the page setting without causing a PageSetup dialogue?
#2 Posted : Wednesday, January 11, 2012 8:57:20 AM(UTC)

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,111

Thanks: 15 times
Was thanked: 141 time(s) in 141 post(s)

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;

Edited by user Tuesday, June 2, 2015 4:58:09 PM(UTC)  | Reason: Igor/10Tec: Added code formatting

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.