Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello guys i need assistance on how to design a reciept for grocery
I have used the code below but it only prints the items on a paper without allowing me to design a proper receipt any assistance will be highly appreciated.

<public void="" mode="hold">
C#
{
            PrintDocument pd = new PrintDocument();
            printFont = new Font("Arial", 12);
            pd.PrintPage += new PrintPageEventHandler(PrintPage);
            pd.DefaultPageSettings.Landscape = true;
            pd.Print();
        }
        private void PrintPage(object sender, PrintPageEventArgs e)
        {

            bitmap = new Bitmap(this.listView1 .Width, this.listView1 .Height);
            listView1.DrawToBitmap(bitmap, this.listView1.ClientRectangle);
            e.Graphics.DrawImage(bitmap, new Point(70, 70));
        }
Posted
Updated 10-Nov-13 21:09pm
v2
Comments
Sergey Alexandrovich Kryukov 11-Nov-13 3:12am    
The question does not seem to make any sense at all. This is your own code which cannot possibly allow or prevent you from designing of anything. Besides, you can draw on the page whatever you need to draw. How can it be a problem?
—SA
BillWoodruff 11-Nov-13 6:41am    
Why not create a special Form, or UserControl, specifically for use as a receipt. Lay out fields as you wish. Then print the Form, or UserControl ?

It really depends on the printer capabilities. If it's a text based printer you'll need to output ESC/POS Commands (for most Receipt printers). If the printer is a raster printer then you can print a bitmap as you have above but of course you'll need to format it.

I suggest in either case you look for a library for e/pos or reporting tool for raster that does the hard work for you.

(E.g. ThermalDotNet (e/pos) on GitHub or similar).
 
Share this answer
 
If your printer has a graphics mode and you've the driver installed, use the 2D .NET graphics tools.

Most General Way:
  • Print whatever will be your decorative top

  • Print line items, totals, etc.

  • Print decorative bottom


Or, with creative setting of page-sizes (i.e., none) you can use the 2D drawing tools for the entire receipt.

In this mode you can use any font, images, overlay things, etc.
BUT ! ! !
You must place the items on the page where you want them to be. Nothing is assumed.

Learning to use the drawing tools is, I have found, a worthwhile endeavor. The same functionality can be used to print to paper or elaborately decorate an application window.

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900