JPS
JPS

Reputation: 21

C# POS receipt printing issue

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

enter image description here enter image description here

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.

Upvotes: 0

Views: 3521

Answers (1)

Rachid OURBATI
Rachid OURBATI

Reputation: 11

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

Upvotes: 1

Related Questions