C#POS收据打印问题 [英] C# POS receipt printing issue

查看:435
本文介绍了C#POS收据打印问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我以图形对象打印收据POS打印机(80×297毫米纸卷爱普生TM-T82)上用C#代码>示例代码如下

 图形图形= e.Graphics; 
字体regularFont =新的字体(宋体,8);
字体titleFont =新的字体(宋体,14);
SolidBrush drawBrush =新SolidBrush(Color.Black);
浮动fontHeight = regularFont.GetHeight();
浮法运行startx = 10.0F;
浮动startY = 5.0F;
INT偏移= 40;
graphic.DrawString(---------------------------------------- ,regularFont,drawBrush,新的PointF(startx的,startY +偏移量),StringFormat.GenericTypographic);
偏移=偏移+(INT)fontHeight + 5;
串头=项目名称.PadRight(30)+价;
graphic.DrawString(头,regularFont,drawBrush,新的PointF(startx的,startY +偏移量),StringFormat.GenericTypographic);
偏移=偏移+(INT)fontHeight;
graphic.DrawString(---------------------------------------- ,regularFont,drawBrush,新的PointF(startx的,startY +偏移量),StringFormat.GenericTypographic);



等等....



现在的问题是,虽然出口成.XPS,那么它显示完美的。不过,虽然在POS打印机打印收据;它减少了列。意思是说,它不打印整行字符串。我试图通过传递的RectangleF graphic.DrawString 来解决这个问题,因为每发现了互联网,但同样的问题的建议。



请参阅.XPS和POS收据附截图






下面,在屏幕截图,收到的边界被标记为黑色。在.XPS该行打印完美(充分页面宽度),但在POS打印机收据,它没有充分宽度(请参阅从切符右侧边框空白)



如果有人能帮助我在这里究竟我做错了。



先谢谢了。


解决方案

请使用columnWidth时propertie结果
的FlowDocument DOC =新的FlowDocument();
doc.ColumnWidth = 700;
doc.PagePadding =新的厚度(20,0,0,0);



我希望这会帮助别人


I have written a code in c# by using graphic object to print the receipt on POS printer (EPSON TM-T82 - paper roll : 80 X 297 mm).

sample code is as follow

Graphics graphic = e.Graphics;
Font regularFont = new Font("Courier New", 8);
Font titleFont = new Font("Courier New", 14);
SolidBrush drawBrush = new SolidBrush(Color.Black);
float fontHeight = regularFont.GetHeight();
float startX = 10.0F;
float startY = 5.0F;
int offset = 40;
graphic.DrawString("----------------------------------------", regularFont, drawBrush, new PointF(startX, startY+offset), StringFormat.GenericTypographic);
offset = offset + (int)fontHeight + 5;
string header = "Item Name".PadRight(30) + "Price";
graphic.DrawString(header, regularFont, drawBrush, , new PointF(startX, startY+offset), StringFormat.GenericTypographic);
offset = offset + (int)fontHeight;
graphic.DrawString("----------------------------------------", regularFont, drawBrush, new PointF(startX, startY+offset), StringFormat.GenericTypographic);

and so on....

Now issue is that while exporting into ".XPS" then it is showing perfect. But while printing on POS printer receipt; it cuts the columns. Meaning to say that it is not printing the full row of string. I tried to fix this issue by passing RectangleF in graphic.DrawString as per suggestions found over internet but same issue.

Please see the attached screenshots of .XPS and POS receipt

Here, in screenshot, the receipt border is marked as black. in .XPS the row is printing perfect (taking full page width) but in POS printer receipt, it is not taking full width (see the white space from cut character to right side border)

If anyone can help me here what exactly i am doing wrong.

Thanks in advance.

解决方案

Please use the columnwidth propertie
FlowDocument doc = new FlowDocument(); doc.ColumnWidth = 700; doc.PagePadding = new Thickness(20, 0, 0, 0);

I wish this will help others

这篇关于C#POS收据打印问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆