简体   繁体   中英

How to set Custom paper size in PrintDocument using C#

I'm using print Document in my project. I've define custom page size in PrintPreview_Click(object sender, EventArgs e). When I print on A4 size paper, it shows result in the center of page (according defined size. but when I replace A4 page with small page. Half of my content didn't print. I've attached Pics of A4 paper print and Small paper. Kindly guide me where I'm Wrong. Thanks in advance.

This is Print Preview

This is the paper where I want to print

This is A4 Result

   private void PrintPreview_Click(object sender, EventArgs e)
        {
            printPreviewDialog1.Document = printDocument1;
            printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 446, 730);
            printPreviewDialog1.ShowDialog();
    }

In addition to setting "DefaultPageSettings.PaperSize", you can try to use "PrinterSettings.DefaultPageSettings.PaperSize" to set the "print area".

printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 446, 730);
printDocument1.PrinterSettings.DefaultPageSettings.PaperSize = printDocument1.DefaultPageSettings.PaperSize;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM