以下是我的代码:
ppvw = new PrintPrevIEwDialog(); ppvw.document = printDoc; ppvw.PrintPrevIEwControl.StartPage = 0; ppvw.PrintPrevIEwControl.Zoom = 1.0; ppvw.PrintPrevIEwControl.Columns = 10; // Showing the Print PrevIEw Page printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); if (ppvw.ShowDialog() != DialogResult.OK) { printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); } printDoc.PrinterSettings.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("a2",5.0,5.0); printDoc.Print();解决方法
PrinterSettings ps = new PrinterSettings();Printdocument recordDoc = new Printdocument();recordDoc.PrinterSettings = ps;
这是一种通过类似’A4’设置纸张尺寸的方法
IEnumerable<PaperSize> paperSizes = ps.PaperSizes.Cast<PaperSize>();PaperSize sizeA4 = paperSizes.First<PaperSize>(size => size.Kind == PaperKind.A4); // setting paper size to A4 sizerecordDoc.DefaultPageSettings.PaperSize = sizeA4;
这是另一种设置自定义纸张尺寸的方法
recordDoc.DefaultPageSettings.PaperSize = new PaperSize("210 x 297 mm",800,800);PrintPrevIEwDialog ppvw = new PrintPrevIEwDialog();ppvw .document = recordDoc;ppvw.ShowDialog();
希望它有效.
总结以上是内存溢出为你收集整理的c# – 设置纸张尺寸全部内容,希望文章能够帮你解决c# – 设置纸张尺寸所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)