首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >收据在打印文档中有重叠的文本

收据在打印文档中有重叠的文本
EN

Stack Overflow用户
提问于 2020-06-02 16:51:56
回答 1查看 243关注 0票数 0

我在POS项目中创建打印收据并附上输出的图片

我这里的问题是描述,数量,价格,数量的重叠。如何在代码的下一行显示数量、价格和金额?

代码语言:javascript
复制
e.Graphics.DrawString("Description" , new Font("trebuchet ms", 10, FontStyle.Regular), Brushes.Black, new Point(0, 260));
e.Graphics.DrawString("Qty" , new Font("trebuchet ms", 10, FontStyle.Regular), Brushes.Black, new Point(120, 260));
//e.Graphics.DrawString("UM" , new Font("trebuchet ms", 10, FontStyle.Regular), Brushes.Black, new Point(190, 190));
e.Graphics.DrawString("Price", new Font("trebuchet ms", 10, FontStyle.Regular), Brushes.Black, new Point(155, 260));          
e.Graphics.DrawString("Amount" , new Font("trebuchet ms", 10, FontStyle.Regular), Brushes.Black, new Point(205, 260));
e.Graphics.DrawString("-------------------------------------------", new Font("trebuchet ms", 12, FontStyle.Regular), Brushes.Black, new Point(0, 275));

int yPos = 300;

foreach (var i in TempVal)
{
  e.Graphics.DrawString(i.Particular + " (" + i.UM + ")", new Font("trebuchet ms", 10, FontStyle.Regular), Brushes.Black, new Point(0, yPos));
  e.Graphics.DrawString(i.Qty, new Font("trebuchet ms", 10, FontStyle.Regular), Brushes.Black, new Point(120, yPos));
  //e.Graphics.DrawString(i.UM, new Font("trebuchet ms", 10, FontStyle.Regular), Brushes.Black, new Point(190, yPos));
  e.Graphics.DrawString(i.Price +".00", new Font("trebuchet ms", 10, FontStyle.Regular), Brushes.Black, new Point(155, yPos));
  e.Graphics.DrawString(i.Total + ".00", new Font("trebuchet ms", 10, FontStyle.Regular), Brushes.Black, new Point(205, yPos));

  yPos = yPos + 20;
}

e.Graphics.DrawString("-------------------------------------------", new Font("trebuchet ms", 12, FontStyle.Regular), Brushes.Black, new Point(0, yPos));
e.Graphics.DrawString("Total Amount:                   Php " + label3.Text.Trim(), new Font("trebuchet ms", 10, FontStyle.Regular), Brushes.Black, new Point(0, yPos+20));
e.Graphics.DrawString("-------------------------------------------", new Font("trebuchet ms", 12, FontStyle.Regular), Brushes.Black, new Point(0, yPos+35));
e.Graphics.DrawString("Cash Tendered:                 Php " + label4.Text.Trim(), new Font("trebuchet ms", 10, FontStyle.Regular), Brushes.Black, new Point(0, yPos + 55));
e.Graphics.DrawString("Change:                            Php " + lblTotal.Text.Trim(), new Font("trebuchet ms", 10, FontStyle.Regular), Brushes.Black, new Point(0, yPos + 75));
e.Graphics.DrawString("-------------------------------------------", new Font("trebuchet ms", 12, FontStyle.Regular), Brushes.Black, new Point(0, yPos+95));
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-02 17:27:51

这将按照您的要求“显示下一行的数量、价格和金额”:

代码语言:javascript
复制
using (var f = new Font("trebuchet ms", 10, FontStyle.Regular))
{
    int yPos = 300;
    foreach (var v in TempVal)
    {
      e.Graphics.DrawString(v.Particular + " (" + v.UM + ")", f, Brushes.Black, new Point(0, yPos));
      yPos += 20;

      e.Graphics.DrawString(v.Qty, f, Brushes.Black, new Point(120, yPos));
      e.Graphics.DrawString(v.Price +".00", f, Brushes.Black, new Point(155, yPos));
      e.Graphics.DrawString(v.Total + ".00", f, Brushes.Black, new Point(205, yPos));
      yPos += 20;
    }
}

请注意,只有当TempVal保证只有在一个页面上所有记录都适合的情况下才能工作。如果有足够多的记录需要更多的页面,那么您必须计算一个页面和split your output onto multiple pages上适合的行数。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62157163

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档