C# software print settings
This article mainly shows you the "C# software print settings", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn the "C# software print settings" this article.
We will encounter some problems in the actual implementation of C# print development, so how to solve these problems of C# print settings becomes very practical. so what are the common problems in implementing C# printing, C# print preview, C# print settings and so on? Let's talk about solving the problem of the change of page margin value of C# print setup control:
Protected virtual PageSettings ShowPageSetupDialog (PrintDocument printDocument) {/ / checks whether printDocument is empty, and throws an exception ThrowPrintDocumentNullException (printDocument) if it is empty; / / declares the return value PageSettings PageSettings ps = new PageSettings (); / / declares and instantiates PageSetupDialog PageSetupDialog psDlg = new PageSetupDialog (); ps = printDocument.DefaultPageSettings; try {/ / the default settings for related documents and document pages psDlg.Document = printDocument; Margins mg = printDocument.DefaultPageSettings.Margins If (System.Globalization.RegionInfo.CurrentRegion.IsMetric) {mg = PrinterUnitConvert.Convert (mg, PrinterUnit.Display, PrinterUnit.TenthsOfAMillimeter);} / / back up the DefaultPageSettings of the printed document, / / because it will change after conversion, / / and the settings dialog box will not display the original value PageSettings psPrintDocumentBack = (PageSettings) (printDocument.DefaultPageSettings.Clone ()) correctly after clicking the cancel button; psDlg.PageSettings = psPrintDocumentBack; / / printDocument.DefaultPageSettings / / if you cancel the dialog box when using printDocument, restore psDlg.PageSettings.Margins = mg; / / display the dialog box DialogResult result = psDlg.ShowDialog (); if (result = = DialogResult.OK) {ps = psDlg.PageSettings; printDocument.DefaultPageSettings = psDlg.PageSettings;} else {}} catch (System.Drawing.Printing.InvalidPrinterException e) {ShowInvalidPrinterException (e);} catch (Exception ex) {ShowPrinterException (ex) } finally {psDlg.Dispose (); psDlg = null;} return ps;} these are all the contents of the article "print setup of C# Software". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!