<summary>///Print button///</summary>//<param name= "Sender" ></param> <param name= "E" ></param> private void Btnprint_click (object sender, EventArgs e) { PrintDocument1 for print control//Set printing paper when set to custom, you can customize the size of the paper, you can also choose A4,a5 and other common paper type This.printdocumen T1. Defaultpagesettings.papersize = new PaperSize ("Custom", 500,300); This.printDocument1.PrintPage + = new Printpageeventhandler (this. Myprintdocument_printpage); Write the format to the Print Preview control for preview printpreviewdialog1.document = printDocument1; Show Print Preview DialogResult result = Printpreviewdialog1.showdialog (); }///<summary>///Printing format///</summary>//<param name= "Sender" ></param >//<param name= "E" ></param> private void Myprintdocument_printpage (object sender, SYSTEM.D Rawing. Printing.printpageEventArgs e) {/* If you need to change the "bold" in the New Font ("bold"), 11, the font will be changed to the one you want, and the number after the blackbody is the size of the font. System.Drawing.Brushes.Blue, 170, 10 System.Drawing.Brushes.Blue is color, the back is the position of the output */e.graphics.drawstring ("Xinxiang March software company Warehousing order", new Font (New FontFamily ("Blackbody"), one), System.Drawing.Brushes.Black, 170, 10); E.graphics.drawstring ("Supplier: Henan Institute of Science and Technology", New Font (New FontFamily ("Blackbody"), 8), System.Drawing.Brushes.Blue, 10, 12); The name of the information E.graphics.drawline (Pens.black, 8, 30, 480, 30); E.graphics.drawstring ("Inbound order Number", New Font (New FontFamily ("Blackbody"), 8), System.Drawing.Brushes.Black, 9, 35); E.graphics.drawstring ("Trade name", New Font (New FontFamily ("Blackbody"), 8), System.Drawing.Brushes.Black, 160, 35); E.graphics.drawstring ("Quantity", New Font (New FontFamily ("Blackbody"), 8), System.Drawing.Brushes.Black, 260, 35); E.graphics.drawstring ("Unit Price", New Font (New FontFamily ("Blackbody"), 8), System.Drawing.Brushes.Black, 330, 35); E.graphics.drawstring ("Total Amount", New Font (New FontFamily ("Blackbody"), 8), System.Drawing.Brushes.Black, 400, 35); E.graphics.drawline (Pens.black, 8, 50, 480, 50); Product Information e.graphics.drawstring ("r2011-01-2016:06:35", New Font (New FontFamily ("Blackbody"), 8), system.drawing.brushes.b Lack, 9, 55); E.graphics.drawstring ("Lenovo A460", New Font (New FontFamily ("Blackbody"), 8), System.Drawing.Brushes.Black, 160, 55); E.graphics.drawstring ("+", new Font (New FontFamily ("Blackbody"), 8), System.Drawing.Brushes.Black, 260, 55); E.graphics.drawstring ("200.00", New Font (New FontFamily ("Blackbody"), 8), System.Drawing.Brushes.Black, 330, 55); E.graphics.drawstring ("20000.00", New Font (New FontFamily ("Blackbody"), 8), System.Drawing.Brushes.Black, 400, 55); E.graphics.drawline (Pens.black, 8, 200, 480, 200); E.graphics.drawstring ("Address: School of Information Engineering, Henan Institute of Technology, Xinxiang", New Font (New FontFamily ("Blackbody"), 8), System.Drawing.Brushes.Black, 9, 210); E.graphics. DrawString ("Operator: Ren bogey", New Font (New FontFamily ("Black Body"), 8), System.Drawing.Brushes.Black, 220, 210); E.graphics.drawstring ("Service Hotline: 15083128577", New Font (New FontFamily ("Blackbody"), 8), System.Drawing.Brushes.Black, 320, 210); E.graphics.drawstring ("Storage time:" + DateTime.Now.ToString (), New Font (New FontFamily ("Blackbody"), 8), System.Drawing.Brushes . Black, 9, 230); }
c#printdocument Print size adjustment