Zebra printer uploading PCX instead of GRF image - zebra-printers

I have two different Zebra printers, the RW420 and the iMZ320.
I am trying to print images on them.
I am using the Java/Android SDK provided by Zebra to first upload the image.
printer.storeImage("R:IMAGE.GRF", ZebraImageFactory.getImage(bmp), ImageUtils.IMAGE_DIMEN, ImageUtils.IMAGE_DIMEN);
On the iMZ320, the image uploads just fine and I am able to print it out.
However, on the RW420, I cannot print the image and when I print the config page with the list of file names, the file is listed as 'IMAGE.PCX'
The printer's language is set to 'ZPL'
Any ideas on why this is happening?

So it depends upon how you created 'printer' in your example. If you used the ZebraPrinterFactory.getInstance(Connection connection) call directly, the SDK will communicate with the printer and determine the type of printer based on a few criteria. For RW420 it will use CPCL as the default language of choice (even though it is in ZPL mode) which will force it to use PCX rather than GRF.
To override this, you can create the printer using the explicit language you wish to use.
ZebraPrinter printer = ZebraPrinterFactory.getInstance(PrinterLanguage.ZPL, connection);

Related

PowerShell Script to set default paper size on an Epson Printer

Epson printers, by default, have a paper size of 80mm x 297mm (or something close to 297)
The datawindow in my program is longer than that, so it prints a second page and duplicates the header.
If you go into the printer properties and set the paper length to 80mm x 2970mm then everything works fine.
I am trying to write a powershell script that will automate this process.
The Printer Name is "EPSON TM-T20IIIL Receipt" and the Paper Size Value that I want it to be set to is "Roll Paper 80 x 3276 mm"
EDIT This is a roll receipt printer
This seems like it would work for a regular printer that has a PaperSize Value of A0-A10. The problem Im facing is that the Epson Roll Receipt printer does not have any of these values. Is there a corresponding value to the size I'm looking for?
Set-PrintConfiguration -PrinterName "EPSON TM-T20IIIL Receipt" -PaperSize A4
Printer size options available
[1]: https://i.stack.imgur.com/Fo0AY.png
Since Epson receipt printers are not what I would say are "normal" printers, you can't use typical Windows print settings to set these values. When printing, you basically only send text and basic commands to the printer. Most of the configuration settings are actually stored in the Flash memory on the printer and not in the driver. For ex. the logos at the start of a receipt is stored on the printer, and not generated at all by the driver. Similarly, options for automatically cutting paper at the end of printing. I believe that paper/roll size falls under these kind of settings because the printer needs to know the width of the paper to know how to handle the text being sent to it (remember, we are only sending basic raw text to the printer, and the printer determines how to print it).
Therefore to configure the printer, while the basic driver is needed, you actually have to use the Epson Advanced Printer Driver to configure the printer, and then use APD to export the configuration. That exported configuration can be used to set up new printers. For ex. using APD v5 driver.
First install and fully configure the printer with all the configurations that you want. (paper/roll sizes, logos, cut/no cut at end of print, etc.)
Export the configuration by running Start -> All Programs -> EPSON -> EPSON Advanced Printer Driver 5 and open Register, Change and Delete EPSON TM Printer
Select the printer, and from the menu select Copy Installation -> Create
Select the installation package type. e.g. I suggest Complete package (with the APD Utility)
Now you can use that installation package to install a fully configured printer on any new machines.

How to save as PDF while printing a document on actual printer

I am trying to find a generalized solution on how to save the document as PDF while giving print on my actual printer on Windows 7/10 OS.
Scenario: Whatever I am printing whether an image or a file or from the third party app like POS or Screen Print (like user press pint button on the third party application or press CTRL+P if the third party app supported this hot key), i need to save the document as PDF which this document is reaching to the actual printer which is printing the hard copies. I wanted to generalized to support all kinds of printers be it dot matrix or laser or thermal etc...
Solution which I have tried out:
Virtual Printer which will print pdf and then route the pdf to the actual printer. But few printers doesn't support PDF like Thermal printer do not support PDF, moreover for this i need to take care of the paper settings and page settings.
I have tried Virtual Printers like Win2PDF / ClawPDF
I have looked into the Windows Printing architecture, and tried saving spool file and listening the printing event and routing the spool file to virtual printer to create pdf. This works partially as some of the printer drivers emits the RAW Spool file.
PCL & Postscript can be fine to convert to PDF.
Using Print processor like PrintMulti but the same issue like the 2nd one.
I have tried to look into the even if I can get some kind of input file from which Windows Printing creating the Spool file, but I am unable to get that.
I tried Printer Pooling but that is like a load sharing kind of things.
Could anyone help me on this. I am unable to find any solution over google as well so posting it here. It looks a normal thing to achieve but even after two weeks i am unable to find any solution for this. Is this something difficult to achieve the generalized solution?
Consider an approach using something like the ePrint Virtual Printer which works by capturing the Windows EMF file from the print job and converting it to PDF while also being able to still send the EMF to the physical printer and print it. The application itself allows for the creation of Print Tasks in a Virtual Printer, which can be configured to save to PDF and batch print to other printers.
On the other hand, ePrint is based on the LEADTOOLS Virtual Printer SDK, which could be useful for you to look into if you are looking to code your own approach.
For example, the code for an event that is hooked to a virtual printer to save the captured EMF as PDF:
// Write the EMF as file to disk as PDF.
static void VirtualPrinter_EmfEvent( object sender, EmfEventArgs e )
{
string pdfPath = Path.Combine(
#"c:\Output\PDF\",
Path.GetFileNameWithoutExtension( Path.GetRandomFileName() )
) + ".pdf";
Directory.CreateDirectory( Path.GetDirectoryName( pdfPath ) );
// Create an instance of the LEADTOOLS DocumentWriter
DocumentWriter docWriter = new DocumentWriter();
docWriter.BeginDocument( pdfPath, DocumentFormat.Pdf );
DocumentEmfPage page = new DocumentEmfPage() {
EmfHandle = new Metafile( e.Stream ) )
.GetHenhmetafile()
};
docWriter.AddPage( page );
docWriter.EndDocument();
}
If you are interested in more details, you can check out this article here.

How to tell the printer to print grayscale or colored content

I have this line of codes that will tell the printer to print a document. But it will only print colored content.
word = Dispatch("Word.Application")
word.Documents.Open(self.filePath)
word.ActiveDocument.PrintOut()
word.ActiveDocument.Close()
word.Quit()
What I want is to tell the printer to print grayscale content. Is there any possible solution for this?
Q: How to tell the printer to print grayscale or colored content?
Short Answer::
You have to talk to the relevant printer driver, which is completely platform- and API-specific.
Longer Answer:
The snippet you showed, word = Dispatch("Word.Application"), is using a Python wrapper to Microsoft Com/ActiveX. Specifically, to the MS-Word COM/ActiveX component (which was presumably registered on your PC when you installed MS-Word).
So all you have to do is look at the options provided by "Word.Application":
https://learn.microsoft.com/en-us/office/vba/api/word.application.printout
Be advised, you might also have to play around with "Printer Device Settings", for example:
https://learn.microsoft.com/en-us/office/vba/api/access.printer

How can I extract text from Win8 print driver generated PostScript file

I can extract text from a Win7 print driver generated PostScript file, but not from Win8.
For example, creating some text in Windows' "Notepad", telling Notepad to print using an HP PostScript print driver, and telling the print driver to output to a file, I obtain a file that I then want to extract text from.
I have tried Ghostscript's ps2ascii and pstopdf | pdftotext and a number of other things on a Ubuntu platform, and while some of these work on the Win7 output, I can not find any combination that work on the Win8 output.
Is there an Open Source solution to this?
You cannot guarantee getting text from any PostScript program, its not designed for that.
However Ghostscript's txtwrite device will do a decent job on the output from the Windows PostScript printer driver. Its much better than ps2ascii because (amongst other things) it can handle Unicode, so its not limited to ASCII.
Beware that applications may generate PostScript themselves, so even if the output appears to be from the Windows PostScript printer driver, the actual content might be generated by the application.
Also you will only get text out of the Windows PostScript printer driver if the application actually writes text to the device context. For example if you print a PDF from the Edge browser then you will get text in the output. If you print the same PDF from Chrome on the same system, then the text is instead rendered as vectors (ie line, arc, stroke fill etc) not text.
Just be aware that what you are trying to do isn't going to be 100% successful in the general case.

Print any document with a textual identifier on it

Is there any possibility of printing any document (e.g. image, PDF, Office document, etc) with a text label at the top of page? Modifying actual files isn't an option for me. I'm wondering if there's anything like that provided in Windows printing system.
Thanks.
Some printers allow you to add a "watermark" to every page they print (but that functionality is all in the printer drivers, now in Windows itself). If that's available to you, you could probably tweak the watermark to be what you need.
Another tactic--but a challenging one!--would be to create your own printer driver that accepts the Print command from any program, just like a printer, then adds the text label you want, then forwards the print job on to a real physical printer.

Resources