Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am printing an image in WPF. The image prints well but the printer (a Thermal Printer) cuts the printed job after reaching an A4 length size thus leaving a whole lot of empty space below and wasting paper. I want the thermal printer to cut the print job after printing the image.

What I have tried:

C#
//instantiate print
                dd = new PrintDocument();
                PaperSize ps = new PaperSize("Size", 300, 400); this is the size of paper thati want printed out. i mean once the print job completes at a height of 400, the paper should be cut by the printer
                var src = dd.PrinterSettings.PaperSources;
                dd.DefaultPageSettings.PaperSize = ps;
                ps.PaperName = "Roll Paper";
                dd.OriginAtMargins = false;
                dd.PrinterSettings.DefaultPageSettings.Margins.Bottom = 0;//i thought this will do the job but unfortunately not
                dd.PrinterSettings.DefaultPageSettings.PaperSize = ps;
                
                    dd.PrintPage += (sed, args) => dd_PrintPage(image, args);
                    dd.Print();


C#
void dd_PrintPage(object sed, PrintPageEventArgs e)
        {
            var img = sed as System.Drawing.Image;
            e.Graphics.DrawImage(img, new PointF(0, 0),);
        }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900