Print PDF and Custom Label Size - c#

I am generating PDF document using iTextSharp (winforms), now i need to print this generated PDF document using a Label Printer.
I have multiple Printers installed on my machine, so with VB.net I need to Select a certain Thermal printer.
Once the Printer is Selected I need to Specify Shipping Label Size (width & height).
So Once Label Printer is selected and I specified custom Label dimensions, I would like the label to be printed without any user action (Like skip the Confitm box to print).
I dont need the full code, I just need someone to put me into right direction.
Thanks

You can use the PrintDocument object. Use the Print method, and do the actual printing in the PrintPage handler. To do this, you can output to the graphics object of the parameter PrintPageEventArgs in your PrintPage handler.

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)

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.

Print coordinates in VB.NET or C#

I have to print invoices from my software. I created the layout with Adobe Illustrator and saved it as a PNG image. My original idea was printing the layout as a background and then print the actual data taken from the database. I printed my layout inside my function and then I measured the various boxes of the layout for correctly placing my text. The problem is that my text is not printed in the correct position that I've found. I tried to change the margins to 0 but it seems to have no effect. I want this: if I choose to print my text line at x=10 mm and y=20mm the text must be phisically printed in this position without scaling/translating, also my background image.
Can you help me?
Try using (e.g.) e.Graphics.PageUnit = GraphicsUnit.Milimeter, and then simply specify the desired values using the Graphics.DrawString Method

Replace text in PDF

I'm trying to replace a section of a PDF with different text. From research on all major PDF libraries for .NET, it seems this is complicated and not a trivial task. I think it may be easier to convert the PDF to an image, replace the text (always in the same place), then convert it back to a PDF (or leave it as an image if converting back isn't possible). Is it possible to extract an image from a PDF page with .NET?
If your text is in a known location, you can simply cover it with a rectangle filled with the background color, and then draw your text over top.
Note that the text will still be there, it simply won't be visible. Someone selecting text will still pick up the old stuff. If that's acceptable, it's quite trivial.
If the PDF was created from image, you can import it into Photoshop to edit it as an graphic. Or you can use screenshot program like "Snagit" to capture pdf page as image and use snagit's editor to erase old text and replace new one.
But this method may bring you problem is that the new added text may not the same font as text around it. Personally, I use pdf editor to replace text in pdf since the added text will be automatically fit with the original font and size.

Categories