0

How can i set default Paper size to 6inch X 3inch. I tried the following code but printing A4.

 private void button2_Click(object sender, EventArgs e)
        {

            try
            {
                PrintDocument pd = new PrintDocument();

                pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
                PaperSize ps = new PaperSize("Custom", 440, 220);
                pd.DefaultPageSettings.PaperSize = ps;
                PageSettings pa = new PageSettings();
                pa.Margins = new Margins(0, 0, 0, 0);
                pd.DefaultPageSettings.Margins = pa.Margins;
                pd.Print();
            }
            catch (Exception ex)
            {
               MessageBox.Show("Error: " + ex.ToString());
           // Response.Write("Error: " + ex.ToString());
            }
        }
afri
  • 49
  • 2
  • 12
  • check this link https://www.codeproject.com/Articles/12229/Adding-custom-paper-sizes-to-named-printers – Kushal Patil Dec 18 '16 at 03:26
  • @KushalPatil Based on the link. How can i set my sizes? I want default size should be 6inchX3inch. Thanks – afri Dec 18 '16 at 04:39

1 Answers1

0

You can user PrinterSettingsclass from the below article: https://www.codeproject.com/articles/6899/changing-printer-settings-using-c

PrintDocument.PrinterSettings would give you available paper sizes from the printer.

Refer to the link below:

Change printer default paper size

Community
  • 1
  • 1
Ambrish Pathak
  • 3,813
  • 2
  • 15
  • 30