C # printing, paper size, font and color

Source: Internet
Author: User

C # printing, paper size, font and color

/// <Summary>
/// Print button
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Private void btnprint_click (object sender, eventargs e)
        {
           
// Printdocument1 is the print control
// Set the paper used for printing. When set to custom, you can customize the size of the paper, and select common paper types such as a4 and a5.
This. Printdocument1.defapagpagesettings. papersize = new papersize ("custum", 500,300 );
This. printdocument1.printpage + = new printpageeventhandler (this. myprintdocument_printpage );
// Print the prepared format to the preview control for preview.
Printpreviewdialog1.document = printdocument1;
// Display, print, and preview
Dialogresult result = printpreviewdialog1.showdialog ();
// If (result = dialogresult. OK)
// This. myprintdocument. print ();
        }

 

/// <Summary>
/// Print format
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Private void myprintdocument_printpage (object sender, system. drawing. printing. printpageeventargs e)
        {
/* If you need to change yourself, you can change the font in the new font (new fontfamily (""), 11) to the font you want, the number behind the simhei indicates the font size.
In system. drawing. brushes. blue, 170, 10, system. drawing. brushes. blue is the color, followed by the output position */
E. graphics. drawstring ("Xinxiang city March software company warehouse receiving ticket", new font (new fontfamily (""), 11), system. drawing. brushes. black, 170, 10 );
E. graphics. drawstring ("supplier: Henan Institute of Science and Technology", new font (new fontfamily (""), 8), system. drawing. brushes. blue, 10, 12 );
// Information Name
E. graphics. drawline (pens. black, 8, 30,480, 30 );
E. graphics. drawstring ("warehouse receiving ticket no.", new font (new fontfamily (""), 8), system. drawing. brushes. black, 9, 35 );
E. graphics. drawstring ("product name", new font (new fontfamily (""), 8), system. drawing. brushes. black, 160, 35 );
E. graphics. drawstring ("quantity", new font (new fontfamily (""), 8), system. drawing. brushes. black, 260, 35 );
E. graphics. drawstring ("unit price", new font (new fontfamily (""), 8), system. drawing. brushes. black, 330, 35 );
E. graphics. drawstring ("total amount", new font (new fontfamily (""), 8), system. drawing. brushes. black, 400, 35 );
E. graphics. drawline (pens. black, 50 );
// Product information
E. graphics. drawstring ("r2011-01-2016: 06: 35", new font (new fontfamily (""), 8), system. drawing. brushes. black, 9, 55 );
E. graphics. drawstring ("Lenovo a460", new font (new fontfamily (""), 8), system. drawing. brushes. black, 160, 55 );
E. graphics. drawstring ("100", new font (new fontfamily (""), 8), system. drawing. brushes. black, 260, 55 );
E. graphics. drawstring ("200.00", new font (new fontfamily (""), 8), system. drawing. brushes. black, 330, 55 );
E. graphics. drawstring ("20000.00", new font (new fontfamily (""), 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 University of Science and Technology, Xinxiang city", new font (new fontfamily (""), 8), system. drawing. brushes. black, 9,210 );
E. graphics. drawstring ("handler: Ren Ji", new font (new fontfamily (""), 8), system. drawing. brushes. black, 220,210 );
E. graphics. drawstring ("Service Hotline: 15083128577", new font (new fontfamily (""), 8), system. drawing. brushes. black, 320,210 );
E. graphics. drawstring ("warehouse receiving Time:" + datetime. now. tostring (), new font (new fontfamily (""), 8), system. drawing. brushes. black, 9,230 );
        }

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.