C# .NET - Printing - Asked By suresh kotte on 20-May-12 10:40 AM

Earn up to 10 extra points for answering this tough question.
Hi,

       I am fresher, and I have making billing application, but i don't know how to write the code for Bill of printing. So plz best reply to me and send a best example.

Thanks &Regards

Suresh.K
kalpana aparnathi replied to suresh kotte on 20-May-12 01:31 PM
hi,

Use below referance for getting discussion of the pos billing printing.

http://social.msdn.microsoft.com/Forums/en-US/posfordotnet/thread/d1dd6b1b-62c8-4ca8-9822-607e277d01f6/

Regards,
[)ia6l0 iii replied to suresh kotte on 20-May-12 01:38 PM
One way is to use report designer's such as Crystal Reports. You should build the custom views/reports using the designer and then print them.

Read more on how to print from MSDN article that talks about the "System.Drawing.Printing Namespace"
http://msdn.microsoft.com/en-us/library/system.drawing.printing.aspx 

Also, note that there is the PrintPageEventHandler which allows you to custom write Images or sections of text during print. Look for detailed sample on the internet.  Here is a brief sample I have. 

//invoke the print document's print method.
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.Print();

//the print page event handler.
//print image

ev.Graphics.DrawImage(Image.FromFile("image file path"), ev.Graphics.VisibleClipBounds);
      

Hope this helps.
Somesh Yadav replied to suresh kotte on 21-May-12 12:22 AM
check this,
http://cboard.cprogramming.com/csharp-programming/113711-csharp-printing-problem.html
http://forums.codeguru.com/showthread.php?t=514118
Jitendra Faye replied to suresh kotte on 29-May-12 12:37 AM
If you are using crystal report to display report then you can simply use PrintToPrinter() method.

like this-

crReportDocument.PrintOptions.PrinterName = PrinterName;

crReportDocument.PrintToPrinter(1, false, 0, 0);

TRy this and let me know.