Graphics.DrawString( "EST ENGENHEIRO MARCILAC, 116, SAO PAOLO - SP", regular, Brushes.Black, 30, 30 ) Graphics.DrawString( "FERREIRA MATERIALS PARA CONSTRUCAO LTDA", bold, Brushes.Black, 20, 10 ) Private void printPage( object sender, PrintPageEventArgs e )įont regular = new Font( FontFamily.GenericSansSerif, 10.0f, FontStyle.Regular ) įont bold = new Font( FontFamily.GenericSansSerif, 10.0f, FontStyle.Bold ) "201", //fill from somewhere in your code If you want it to be printed well formatted with different fonts (bold, regular), you have to do it all manually: List itemList = new List() If you send a plain string to your printPage(object sender, PrintEventArgs e) method, it will just print plain text in all the same font which looks 'messy' (as you named it) So if you want to print directly without showing output to the user, you can handle DocumentCompleted event and call Print there. You should call Print after the document completed. = rpt.TransformText() Ĥ- If you want to print the report, you can call: () Report.ReportPath = void Export(LocalReport report) , Using RDLC, but it is very slow to start print. Check to see if more pages are to be printed.Į.HasMorePages = (stringToPrint.Length > 0) StringToPrint = stringToPrint.Substring(charactersOnPage) Remove the portion of the string that has been printed. Graphics.DrawString(stringToPrint, this.Font, Brushes.Black,Į.MarginBounds, StringFormat.GenericTypographic) Draws the string within the bounds of the page Graphics.MeasureString(stringToPrint, this.Font,Į.MarginBounds.Size, StringFormat.GenericTypographic, of stringToPrint that will fit within the bounds of the page. Sets the value of charactersOnPage to the number of characters Private void printPage(object sender, PrintPageEventArgs e) PrintDocument.PrintPage += new PrintPageEventHandler(printPage) = DefaultPrinter.GetDefaultPrinterName() ![]() ![]() Writer.WriteLine(" NOME DA EMPRESA AQUI ") įileStream fs = new FileStream(COMPROVANTE, FileMode.Open) StreamWriter writer = new StreamWriter(fs) Private void button1_Click(object sender, EventArgs e)įileStream fs = new FileStream(COMPROVANTE, FileMode.Create) Private static String RECEIPT = Environment.CurrentDirectory + String stringToPrint = "" private PrintDocument printDocument = new PrintDocument() When I do print the text file is printed, but all messy, and after the end print the paper isn't stopping. To do this I'm creating a text file and reading it to print using the PrintDocument but I cannot do this because I don't know how to configure paper size, align text center on the paper, and others configurations. I'm creating an application using C# with Winforms and now I need to print the receipt of sale on a thermal printer.
0 Comments
Leave a Reply. |