C # enables printing capabilities to set paper size, font and color

Source: Internet
Author: User

 /// <summary>        ///the printed button/// </summary>        /// <param name= "Sender" ></param>        /// <param name= "E" ></param>        Private voidBtnprint_click (Objectsender, EventArgs e) {            //printDocument1 for print controls//set the paper for printing when set to custom, you can customize the size of the paper, you can also choose A4,a5 and other common paper type             This. printDocument1.DefaultPageSettings.PaperSize =NewPaperSize ("Custom", -, -);  This. printdocument1.printpage + =NewPrintpageeventhandler ( This.            Myprintdocument_printpage); //give the print preview control a well-written format for previewingPrintpreviewdialog1.document =PrintDocument1; //Show Print PreviewDialogResult result =Printpreviewdialog1.showdialog (); }        /// <summary>        ///format of printing/// </summary>        /// <param name= "Sender" ></param>        /// <param name= "E" ></param>        Private voidMyprintdocument_printpage (Objectsender, System.Drawing.Printing.PrintPageEventArgs e) {            /*If you need to change yourself in the new font ("bold"), the "Blackbody" in the FontFamily is changed to the font you want, the number behind the blackbody represents 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",NewFont (NewFontFamily ("blackbody"), One), System.Drawing.Brushes.Black, the,Ten); E.graphics.drawstring ("Supplier: Henan Institute of Science and Technology",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Blue,Ten, A); //the name of the messageE.graphics.drawline (Pens.black,8, -,480, -); E.graphics.drawstring ("Inbound Order Number",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black,9, *); E.graphics.drawstring ("Product Name",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black, the, *); E.graphics.drawstring ("Quantity",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black,260, *); E.graphics.drawstring ("Unit Price",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black, the, *); E.graphics.drawstring ("Total Amount",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black, -, *); E.graphics.drawline (Pens.black,8, -,480, -); //Product InformationE.graphics.drawstring ("r2011-01-2016:06:35",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black,9, -); E.graphics.drawstring ("Lenovo A460",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black, the, -); E.graphics.drawstring (" -",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black,260, -); E.graphics.drawstring ("200.00",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black, the, -); E.graphics.drawstring ("20000.00",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black, -, -); E.graphics.drawline (Pens.black,8, $,480, $); E.graphics.drawstring ("Address: Xinxiang College of Information Engineering, Henan University of Science and Technology",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black,9, About); E.graphics.drawstring ("Manager : Ren bogey",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black, -, About); E.graphics.drawstring ("Service Hotline: 15083128577",NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black, the, About); E.graphics.drawstring ("Storage Time:"+ DateTime.Now.ToString (),NewFont (NewFontFamily ("blackbody"),8), System.Drawing.Brushes.Black,9, the); }

C # enables printing capabilities to set paper size, font and color

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.