Please help me on how to set my paper size in c# code. I am using the API printDocument.
Below is my code:
ppvw = new PrintPreviewDialog();
ppvw.Docume
PrinterSettings ps = new PrinterSettings();
PrintDocument recordDoc = new PrintDocument();
recordDoc.PrinterSettings = ps;
here's a way to set the paper size by kind like 'A4' for example
IEnumerable paperSizes = ps.PaperSizes.Cast();
PaperSize sizeA4 = paperSizes.First(size => size.Kind == PaperKind.A4); // setting paper size to A4 size
recordDoc.DefaultPageSettings.PaperSize = sizeA4;
and here's another way to set a custom paper size
recordDoc.DefaultPageSettings.PaperSize = new PaperSize("210 x 297 mm", 800, 800);
PrintPreviewDialog ppvw = new PrintPreviewDialog();
ppvw .Document = recordDoc;
ppvw.ShowDialog();
Hope it works.