Printing text and images on an LPT port - c#

I'm working on c#.net application that already use serial port to print ticket with text and a little image as logo by thermal printer.
Now i need to migrate the implementation to allow application to print through Parallel Port because the hardware is changed...
For serial port (COM1...COMN) i used ESC/POS command..
is it possible continue to use ESC/POS and redirect the print to parrallel?..
exist documentation?..
i found many doc to print text only .
what i have to do to print image?
thanks

.NET abstracts printing from the printer, so the code is the same regardless of whether the printer is serial, on the network, connected via parallel port, or connected via bluetooth. To print an image, you would use the DrawImage method of the Graphics object--more detail can be found on MSDN.
Whether the printer is on parallel port or serial port is a function of how the printer is defined in Windows, and is not important to .NET.
However, if you are resorting to sending raw escape sequences and bypassing the use of a printer driver (such as referenced by ESC/POS), then you are making a whole world of extra work for yourself, and you'll need to refer to the printer's technical documentation for how to do what you ask.

Related

How to: Standalone C# printing on Epson Thermal printer

For the first time I've been given this Thermal printer (M325A) to use, at this stage I have ZERO idea of how to code my desktop application to print "ANYTHING". But my present requirement will be to print just 4 lines of information:-
Pre-mentioned Static Banner (Big text),
User supplied numeric value (Non-Decimals),
Serial Number (Progressive),
Current Date & Time.
Kindly help me start.
While there are printing libraries out there, you can as well directly connect to the printer, over serial, USB, or, ethernet, and send it the commands to print. ESC/POS capable printers interpret escape sequences, which are very well documented. You must, however, get to know how you can send binary data (i.e. 8-bit bytes) directly to the printer.

UWP Printing from Windows app directly without bringing Print Dialog

Does POS printer just support Epson printers? (related to https://msdn.microsoft.com/en-us/library/windows/apps/mt426652)
How to send a document directly to the printer without showing Print Dialog?
ESC/POS is a command system created by Epson used across a wide range of POS printer systems, aimed at avoiding incompatible command sets by providing universal applicability. Most modern printers support ESC/POS.
So, for your first question, I think the answer is no. This POS printer API can be used for all the printers which support ESC/POS. Please refer to Epson ESC/POS with formatting.
For your second question, using POS printer API, you can print without a Print Dialog.
But I assume, what you want is Windows.Graphics.Printing namespace. For this printing in a UWP app, the Print Preview UI must be shown to guide user complete the printing operation.
You can refer to the official POS printer sample and Printing sample.
Update 2/1/2016:
using POS printer API, you can print without a Print Dialog.
#Seb, this is my personal conclusion, the official document of POS printer doesn't mention anything about a UI dialog.
But in the short sample in the document and official sample, when we print with a pos device, we create a print job at first, then call the PrintLine(string) method with the content which we want to print, at last, we execute it/them with ExecuteAsync method, this method
Runs the print job on the receipt printer station asynchronously.
In this process, we don't show any dialog unlike in the normal printing. In the normal printing, when we want to print a document from our app, we call ShowPrintUIAsync() method, this method will show a dialog to provide guidance for users to help them complete a printing-related oricess.
#Hamed, this Pos printer API can't support those device without ESC/POS, I'm not sure if it possible to send commands to your printer and get response from it through serial port, I think you may read the develop document of your printer.

How to print directly to a printer connected to serial port via .net desktop application

I've been working on a desktop application built using .NET Framework 4.5 and C# as language. Requirement is that a printer will be connected on serial port, port settings will be provided by user through the application like port number, baud rate etc. etc.
When user hits a print button, it should directly print to the printer without showing a print dialogue.
I've never done printing from desktop application and i've no idea how to achieve this.
Should i have to code specific to driver of that printer?
Or is there any generic way to send print instructions to printer connected to serial port?
I can send normal string to serial port, but what if i need to do some formatting like drawing a table, how can i make a serial port printer printing a formatted table and values inside it ... for example a bill.
Any help would be greatly appreciated.
Thanks,
Amit
You will want to send ESC/POS commands. This will control the font, line height, etc. as well as the actual text being transmitted.
http://pyramidacceptors.com/cms/wp-content/uploads/2013/02/ESC_POS_Protocol_Commands_REV_B.pdf
Another userful SO question: How to use esc/pos command with c#?
Also, no need to reinvent the wheel. Check Github for a library: https://github.com/yukimizake/ThermalDotNet
As far as generating tables and other such non-text, you'll want to read up on the command set supported by your target printer. If you're printing a bill, it sounds like you are targeting a thermal printer. Image/non-text support will vary from model to model.

Are there any virtual printer driver for ESC/POS commands to test while programming?

I am writing a sample program to send raw data to ESC/POS printers (not a specific but printers supporting esc/pos in general) using C# .net.
ESC/POS Command Reference: https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=2
So, as you can I am using that above guide to send raw data. But, I do not have a physical printer available while I am coding. So, I am looking for a temporary solution for basic testing.
Are there any virtual printer drivers available where I can send the raw data from my application to and see how it looks? For example: you can install virtual pdf printers etc. But, I need one that can parse the esc\pos and output in either *.pdf or any images or text formats.
I'm not sure if this is still applicable for you, but I've found this solution:
https://www.colorpilot.com/emfprinterpilot.html
I hope that's something you were looking for.

Developing an utility for rendering ZPL code of Zebra printer (105 SL) [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Print preview ZPL II commands using .NET WinForm before sending it to Zebra printer
I start developing an utility on .NET 4.0 for Zebra Printer 105SL. Maybe someone know these devices.
I have some questions:
I've just started learning ZPL code. Does it exist some utility for rendering Zebra printer code (ZPL)? For example input is ZPL code and output is some label image.
Does it exist a library for rendering ZPL code? Input is ZPL code output is some image.
Now I can print on Zebra printer only if Zebra printer is installed localy on computer. So next step is to know only IP adresses of Zebra printer. Zebra printer will not be installed on computer on which the user will use my utility. I need to find a way to send data (print) to Zebra printer by IP adress.
Maybe I have many stupid questions but thanks for everybody who will help me.
This isn't exactly the same question, but this answer seems to be what you want?
Send data to thermal printer
Like George said, this question addresses sending ZPL to a printer.
Sending ZPL to a network printer should be no problem, just use the network printer name.
For images, they need to be in PCX format. You first send the PCX file to the printer (using the same method that you send other ZPL commands), then you send the ZPL referencing the image in the printer's memory. It's easier to get a grasp on how this is done by generating a label with a picture in Zebra Designer and looking at the ZPL it generates (check Print to File in the printer dialog).
For your second question, there is no library for this. ZPL is a proprietary language and Zebra doesn't offer libraries to turn ZPL into an image. There is, however, a way to do something like this with the printer's web page (available for some printers).
Click on the Directory Listing section of the printer, then click on "Create New Script".
Here you can type in ZPL and then choose "Preview Label" and that should show you what the label will look like

Categories