Print on thermal paper - c#

I need to print a receipt on thermal paper from Crystal Reports. I created a print layout which works fine if printed from the preview. If I try to print from code, the printer just rolls out empty paper. The printer is installed properly (POS58). How can I properly print this from code?
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(Directory.GetCurrentDirectory() + #"\Reports\receipt.rpt");
rptDoc.SetParameterValue("pOrderID",OrderID);
rptDoc.PrintOptions.PrinterName = "POS58";
rptDoc.PrintToPrinter(1,false,0,0);

Since I can't comment on your question, I am going to ask you here: Do you have any data on the report to show? I don't see any datasource assignment in your code, so maybe you need to provide some data to be printed.
Have you tried setting the paperSize in your code using the PrintOption in your report? I did this once; I was printing to a receipt printer but my paper was set to A4 so my actual report data were printed outside of the receipt paper. Try to send your document to a printer with A4 paper or better yet send it to oneNote so you don't waste paper and see how it prints.

Related

Zebra printer stop each label

Zebra model: Zebra Z4M
I have a problem with printing labels from a PDF file on a Zebra printer. If I send a file to be printed that has several pages (one page = one label) the printer prints one page, pauses for 2 seconds, and prints another label (instead of printing continuously)
I create C# app where I generate simple PDF file (using iTextSharp) and print it on Zebra (i send file to Zebra one file who contain multiple pages -> each page == one label)
In iTextSharp i create PDF file with custom dimension:
var pgSize = new iTextSharp.text.Rectangle(353, 180);
Document pdfDocument = new Document(pgSize, 0, 0, 0, 0);
In printer i set dimensions corresponding to the actual size of the label:
P.S.
I noticed that if I send a PDF file for printing with only one page, but by setting the number of copies (e.g. to 5 copies) the printer prints normally (without pausing on each label)
It reads the PDF one page at a time, after printing the first page it will clear it from memory then convert and load the second page.
This printer is discontinued, PDF is not easy to print, especially for old models.
I recommend using ZebraDesigner Professional software for better printing performance, it is more optimized for Zebra printers and have many great options (see image below)

Rdlc report vertical barcodes

I have a problem in rdlc report in Visual Studio 2019 printing barcodes (2of5 or 3of9). In horizontal mode they are all OK, but in vertical property (WritingMode), the barcode does not show all bars correctly.
In design mode on screen, with a static barcode, all looks OK. But when is printed in PDF or on paper the barcodes have different struct. I try set DpiX and DpiY in DeviceInfo string to 1200 but nothing change. Is this an exist any bug? Any help?
Sample of barcodes:
sample2
From my experience, when something does not visualize on rdlc, it's usually a matter of size of the control placed on the report.
If the barcode you're trying to print is too big for the control size you set, then it will be removed by rdlc.
Try to test this by putting the barcode control in an empty area of the report and making it quite big and see if the barcode appears.
The elements you provided at the moment are insufficient to understand what actually is happening.

how to set page size in crystal report for thermal printer in C# windows application

I know width of thermal printer is 3 inch or 4 inches but i did not know how to set height of receipt in my crystal report. If i set it 6 to 10 inches and my product in invoice is more then 4 then my footer of receipt is gone ,please suggest me what to do.
Thanks in advance.
Thermal printer should cut off when it read a cut command .
Try call cut command after print the report, no need to set height I believe.

How to print customized barcode labels

I have a windows application which is responsible for printing customized barcode labels roll based on user's needs like specifying the texts, dimensions and size.
The user will use Zepra and TSC barcode printers, I just need to know how to let the user choose determine the size of label and the space between labels and also the all margins (top, right, bottom and left).
I need a code-snippet does that in C# and the final result to be like this.
So, any ideas?
For Zebra part:
Here is an example how to send ZPL commands into printer:
https://km.zebra.com/kb/index?page=content&id=SA301&cat=ZISV_PL_ZPL&actp=LIST
Here you can find pdf document from ZPL commands which are send to printer. Build a suitable set of codes which will produce the label and barcode that you need:
https://www.zebra.com/content/dam/zebra/manuals/en-us/software/zpl-zbi2-pm-en.pdf
Happy Coding!

C# POS receipt printing issue while print commands directly to the printer, bypassing the driver

As per suggestion and provided link by #HansPassant and #Juan from (C# POS receipt printing issue), i have made the changes in code and now writing the print commands directly to the printer, bypassing the driver (using RawPrinterHelper class). But still there is an issue with the POS printer receipt. It is not taking full width to print the row though the text is not cutting now and it is showing as full text (Screenshot attached)
But as you can see in screenshot, there are enough space left in between the right side border (Marked black) and where the text ends. If text is large string then it breaks into new line but not printing to the right side.The receipt is printing with max width which is up-to the end of dotted line.Rest right side part is blank.
Also, Can you tell me how to print Rupee Symbol before the price or amount while writing the print commands directly to the printer. Earlier when i was using the printer driver for a POS printer, there in c# code i was writing as following:
CultureInfo ci = new CultureInfo("hi-IN"); String.Format(ci, "{0:c}",ProductPrice);
But this is not working with print commands directly to the printer. It prints as "?" as you can see just before the price of each item in attached screenshot.
Thanks in advance.

Categories