title: Format a receipt with WinForms Application
body: <p>I'm working with a restaurant bill printing software.</p>
  
  <p>I've developed a receipt. but they don't look actually like a receipt. </p>
  
  <p>I've followed a solution from codeProject. Here is my code of building a receipt:</p>
  
  <pre><code>//Get the Graphics object
          Graphics g = printTextEvArgs.Graphics;
  
          //Create a font Arial with size 16
          Font font = new Font("Arial", 10);
          float fontHeight = font.GetHeight();
          string underLine = "------------------------------------------";
  
          int startX = 10;
          int startY = 10;
          int offset = 40;
  
          //Create a solid brush with black color
          SolidBrush brush = new SolidBrush(Color.Black);
          if (RecieptType == "ktcprinter")
          {
          }
          else if (RecieptType == "billprinter")
          {
              g.DrawString(restaurantInfo.name, new Font("Courier New", 16), new SolidBrush(Color.Black), startX, startY);
              offset = offset + (int)fontHeight + 20;
  
              var wc = new WebClient();
              Image imgFromUrl = Image.FromStream(wc.OpenRead(b.restaurant_info.logo));
              g.DrawImage(imgFromUrl, 60, 40, 150, 100);
  
              offset = offset + (int)fontHeight + 50;
  
              g.DrawString("Address: " + restaurantInfo.address, new Font("Courier New", 12), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + (int)fontHeight + 5;
              g.DrawString("Phone: " + restaurantInfo.phone, new Font("Courier New", 12), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + (int)fontHeight + 5;
              g.DrawString("Vat Reg. No.: " + restaurantInfo.vat_reg_no, new Font("Courier New", 12), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + (int)fontHeight + 5;
              g.DrawString("Served By: " + employeeInfo.served_by, new Font("Courier New", 12), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + 13;
              g.DrawString(underLine, new Font("Courier New", 12), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + 13;
  
              foreach (var item in b.items)
              {
                  string menuTitle = item.menu_title + item.quantity + item.price;
                  g.DrawString(menuTitle, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + offset);
                  offset = offset + (int)fontHeight + 5;
              }
  
              //Get UnderLine
              offset = offset - 8;
              g.DrawString(underLine, new Font("Courier New", 12), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + 15;
  
              g.DrawString("Sub Total: " + calculation.sub_total, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + (int)fontHeight + 5;
              g.DrawString("Discount: " + calculation.discount, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + (int)fontHeight + 5;                
              g.DrawString("Vat: " + calculation.vat, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + (int)fontHeight + 5;
              g.DrawString("Service Charge: " + calculation.service_charge, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + (int)fontHeight + 5;
              g.DrawString("Delivery Charge: " + calculation.delivery_charge, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + offset);
  
              //Get UnderLine
              offset = offset + 12;
              g.DrawString(underLine, new Font("Courier New", 12), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + 12;
  
              g.DrawString("Total: " + calculation.total.PadRight(30), new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + (int)fontHeight + 5;
  
              //Get UnderLine
              offset = offset - 11;
              g.DrawString(underLine, new Font("Courier New", 12), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + 13;
  
  
              foreach (var item in b.payments)
              {
                  string paymentMethod = item.method + item.amount;
                  g.DrawString(paymentMethod, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + offset);
                  offset = offset + (int)fontHeight + 5;
              }
  
              g.DrawString("Change: " + calculation.change, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + (int)fontHeight + 5;
              g.DrawString("Pay Tip: " + calculation.pay_tip, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + offset);
              offset = offset + (int)fontHeight + 5;
              offset = offset + 20;
  
              //offset = offset + 20;
              //g.DrawString("Total To Pay".PadRight(30) + string.Format("{0:c}"), variable, font, new SolidBrush(Color.Black), startX, startY + offset);
          }
  
          //Draw "Hello Printer!";
          //new Rectangle(margin X, margin Y, Width, Height)
          //g.DrawString(printString.ToString(),
          //font, brush, new Rectangle(5, 0, 350, 500));
      }
  </code></pre>
  
  <p>What I got is like the below image. I want to make it like a real receipt.</p>
  
  <p>The quantities shall be in a column and the price in another column. </p>
  
  <p>(Note that, The solution I followed worked perfectly for them.)</p>
  
  <p>My output at the moment:</p>
  
  <p><a href="https://i.stack.imgur.com/UDA4U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UDA4U.png" alt="enter image description here"></a></p>