Command line print via GhostScript is handling printer settings differently if using print dialog - printing

I'm trying to print a PDF file via GhostScript command and want
to keep alive the default printer settings be done within the system environment (Windows 10 - set paper tray 3 as default).
When is done so without silent mode by using the upcoming printer dialog this works fine (even without setting up paper tray especially)
BUT - as I want the process to be done without dialog - I've also tried it with defining the printer name within the command line.
What works properly, is that the print out happens without dialog - BUT the default configured paper tray doesn't get used - when I print silently - paper tray 1 is used
Is there a possibility to keep the default paper tray settings alive while naming the printer within the command line?
Here is my codeline:
gswin64c.exe -dPrinted -dNoCancel -dBATCH -dNOPAUSE -dNOSAFER -q -dBitsPerPixel=4 -sDEVICE=mswinpr2 -sPAPERSIZE=a4 -sOutputFile=%printer%" + "\"" + printerName + "\"" +" " + "\""+pdfFileName+ "\"";

To the best of my knowledge, the mswinpr2 device always uses the default setup of the printer, unless you get a print dialog, in which case you can override the default.
Perhaps the default tray isn't the one you think it is.

Yes - I'm sure that the paper tray is set correct (tray3)
It is used when printing with other applications and also when I print via Ghostscript using a print dialog but not when I send a print job silently via command line.
Oliwan

Related

Zebra g420d - light flashes green but nothing is printed

I'm trying to print labels on a Zebra g420d printer, it's setup with CUPS and connected through USB to a Raspberry PI. It works excellent for printing PDF-labels so no problems with communication.
Now I create a secondary queue which is setup as a raw local printer in CUPS to print another type of labels, this time it's not PDF's, instead it's just ZPL. I print with the following command:
lpr -P <PRINTER_NAME> -o raw <FILENAME.zpl>
The green light flashes and file disappears from queue but nothing is printed. Things I have tried:
Using ZPL-driver instead of raw
Different very basic ZPL-labels, some directly from ZPL examples in documentation.
Rendering the label on http://labelary.com/viewer.html, downloading file and send to printer
ZPL with and without linebreaks after each command / at the end
I suspect something might be wrong with encoding of ZPL-commands so I enabled dump mode, here's a photo of the output with hex codes. Note that it's three tries after each other.
dump mode output
One of many ZPL-labels tried:
^XA^FO1,80,0^ADN,25^A0N,100,80,3214^FD123^FS^FO280,80,0^BY3^BCN,150,Y,N,Y,A^FD456^FS^XZ
CUPS Setup:
Description: Zebra Technologies ZTC GK420d
Location:
Driver: Local Raw Printer (grayscale, 2-sided printing)
Connection: usb://Zebra%20Technologies/ZTC%20GK420d?serial=28J2007020XX
Defaults: job-sheets=none, none media=unknown
Any ideas what the reason for this behaviour could be or what to try next?

After printer restart, settings are lost

I am using GX430t Zebra printer.
My problem is that after printer restart, printer is no longer printing special characters for Slovenia.
(example file for printing is below).
Example:
Printer is restarted and then we print example file from our application (we have our own app for printing labels). Slovenian characters are not printed:
Next step is to send that same file into printer via printer settings:
File is printed correctly:
What is even more interesting is that every file printed from our application is OK, after that step is done.
My question is: where does printer stores info about that? What I would like to do is include (if possible) this information into every file that I am printing, so regardless if printer was restarted or not, Slovenian characters will be printed correctly. Otherwise, we must use printer settings and sending example file to printer each time printer is restarted.
Example file with zebra language:
^XA^LH300,10^FO10,10^A0,20,20^FD Šazoćeđa gostinstvo d.o.o.^FS^FO10,20 ^A0,20,20^FDIme polizdelka: ^FS^FO10,40 ^A0,35,35^FDŠABAN ŠAULIĆ^FS^FO10,80 ^A0,30,30^FDDatum predpriprave: 25.04.2018^FS^FO10,120 ^A0,30,30^FDUporabno najmanj do: 25.04.2018^FS^FO10,160 ^A0,20,20^FDOddelek predpriprave: Centralna predpriprava^FS^FO10,190 ^A0,30,30^FDOddelek finalizacije: HKJ_topla kuhinja^FS^FO10,230 ^A0,30,30^FDKoličina: 7 (nar.); 0 (dos.); 7 (ned.); kg^FS^FO10,265 ^FB650,12,, ^A0,20,20^FDSestavine: MOKA PSENICNA T500 1KG (aler.: Gluten; psenica;); SOL KAMENA ; JAJCNI MELANZ (aler.: Jajca;); MLEKO SVEZE 10L (aler.: Mleko;)^FS^FO10,560 ^A0,20,20^FDPripravil: Šaban Šaulić^FS^XZ
Thanks to #banno - solution was to put proper encoding into .ZPL file. In my case, taken from this it was enough to add ^CI28 after ^XA

InvalidPrintCommand error when calling SalReportPrint() function

The application was written in TD 6.2 version. When trying to print using builtin function SalReportPrint()-InavlidPrintCommand error has been received. I have already tried Menu Report->Format->Report option( qrp file) and selected the check box use defult printer option but still getting same error.
had this case several times, using an older version of TD (4.1).
There my problem was that either the printer which it reported that it should be printing on was not installed or it wasn't set as a default printer.
Try to set your printer of choice to be default printer, using SalPrtSetDefault() before you do the printing action.

How to send text file to printer

As i read in some fingerprint manual we can send text file to the printer. Means we can write the program in the text editor and send the whole program as a text file to the printer using the communication program using some transfer commands.
for in my host there is a file called myfile.txt in D:/ with the fallowing data
10 PRPOS 200,200
20 DIR 3
30 ALIGN 5
40 PRIMAGE “GLOBE.1”
50 PRINTFEED
RUN
How can i send this file to printer and execute the instrucations to print the image.
Please give me some code reference.
There are several ways to do this from the command line. For example:
type foo.txt > lpt1:
Or
copy foo.txt lpt1:
Or
print foo.txt
Or
notepad /p foo.txt
If you need to do it programmatically, you can execute any of those commands using the system() function or CreateProcess().
If you're on an Intermec handheld and you're connected to a Bluetooth printer, you should be able to open a serial port to COM6 and send your file over. What programming language? There should be plenty of Serial Port communication code examples out there.
My experience with Intermec PM4i label printer was a roller coaster but know I have a working app.
I tried Windows printer pipeline through generictext driver. It does work from Notepad but with few corner cases.
Printing directly from Notepad works fine until I tried QRCODE image with a very long text line. Image did not print out. Made qrcode text a short few characters and same script worked fine.
INPUT OFF
NASC 1252
BF OFF
FT "Swiss 721 Bold BT",12,0,100
PP 50,500:PT "Text line goes here"
PP 400,400:AN 7:BARSET "QRCODE",1,1,7,2,4
PB "ABC123 aabbcc....very long text goes here...I mean about 200 chars or more"
PRINTFEED
It was like Notepad cut text to a right side border and command string was broken. I made a printing preferences A3-landscape and it accepted longer text but still was not enough for all use cases.
All printers have a physical max printing width but it should not be considered in a fingerprint/directprotocol script files. After all we are not printing this text as-is but submitting commands to the printer.
My solution was to create Java application which opens a raw TCP socket to 11.22.33.44:9100 address and writes text lines, lines terminated by NL(#10). Works fine. Another helper tool I did was Delphi app.exe to read IP address from Windows printer object. I can submit label printouts "directly" from Excel application.
End users edit Excel data rows and click PRINT LABELS button
vba macro parses a fingerprint template file with ${FIELD1} find-and-replace substitutes
file is written to %wintemp%/intermec_script.txt folder
call app.exe to read IP address of user chosen printer
call java app to submit intermec_script.txt to IP:PORT socket
I should create same socket submit app in Delphi to drop javavm dependency but this solution was faster for my use case. I am more familiar with Java than my Delphi skill level.

Zebra Printing with CUPS no print ZPL or EPL

I have a Zebra GK420d connect to OS X via CUPS. However, when I send files to it that are written in ZPL or EPL they are only printed in plain text.
Am I required to change to mode on the printer?
Contrary to what others said, you don't need to specially add a raw queue.
Instead, you can submit raw files into any queue using -o raw switch:
lpr -P CupsPrinterName -o raw path/to/label.zpl
Printer name can be found over that link in CUPS:
http://localhost:631/printers/
This also works on other platforms that use CUPS, like Linux.
You can create a raw CUPS queue with lpadmin. Here's the command line I used:
lpadmin -p Zebra -E -v usb://Zebra%20Technologies/ZTC%20LP%202824%20Plus?serial=XXXXXX -m raw
You can also set up a raw queue using the CUPS web admin at
http://127.0.0.1:631/
This is a bit more comprehensive answer since I seem to be returning to this question every couple of years. To print with a Zebra or other barcode printers in Linux from command line follow these steps:
List all printer targets and find the printer you want to use:
$ lpinfo -v
network https
serial serial:/dev/ttyS0?baud=115200
serial serial:/dev/ttyS1?baud=115200
network lpd
direct hp
direct usb://GODEX/G500?serial=162203C6
network smb
...
Add new queue:
$ lpadmin -p godex -E -v usb://GODEX/G500?serial=162203C6 -m raw -o usb-unidir-default=true
If your printing is slow (takes long to start), please make sure you added -o usb-unidir-default=true.
Check available queues:
$ lpstat -v
device for godex: usb://GODEX/G500?serial=162203C6
Create a label (text file):
Create a file according to your printer's requirements in EPL (Zebra), ZPL (Zebra), EZPL (Godex).
Warning, certain CUPS versions might have an issue with raw files if they are under 512 bytes of length - longer files will print, while shorter will print once and then stall for a couple of minutes (looks like there is a timeout built in). A workaround is to add comments to extend it over 512 byte limit.
Example Zebra file (test.epl):
N
A20,20,0,2,1,1,N,"text"
B20,40,0,1,1,1,30,N,"aaaa-bbbb-cccc"
P1
Example Godex file (test.ezpl):
;set portrait orientation
^XSET,ROTATION,0
;set height 20mm
^Q20,1
;set width 64mm
^W64
;start label
^L
;AA=print out text with smallest font, x=20dots, y=20dots, magnificationx=0, magnificationy=0, gap=1dot, rotationInverse=0 (no)
AA,20,20,0,0,1,0,Some sample text
;BQ=code128, x=20dots,y=40dots,narrow_bar_width=1,wide_bar_width:2,height=30dots,rotation=0deg,readable=0(no)
BQ,20,40,1,2,30,0,0,1234-1243-43214-432141
;end label
E
Push to printer:
$ lpr -P godex test.ezpl
You would need to avoid any filtering. Print using a RAW filter, as configured in the CUPS interface, or by default in your lpadmin statement. You did not state how the printer was connected, but if IP, your destination would most-likely be socket://ip.addr.ess:9100.
I am a PC guy so I don't know CUPS well, but I have used zpl and epl on PC's and found that they really like to get the raw print files. I always do a :
filecopy "c:\zplfile.txt" "\computername\printershare" type command.
I have used wordpad too, if I just want to do some text. But for labels and barcodes I would see if there is a way for you to send the raw zpl or epl to the printer port. Hope this helps.
Thanks. I have looked at it some more. It seems that while using cups you cannot send raw ZPL commands to the printer. Like what I did was create the printer in cups as a socket and started a netcat listener on 9100 and then issued some sort of command to the printer
nc -l localhost 9100
zpl_mine="^XA ~SD10 ^PW 850 ^MM T ^MN W ^JUS ^XZ,";echo $zpl_mine | nc localhost 9100 -w 1
and this does not send the information to the printer, but I have seen on some forums that you have to use some form of language like C to parse the information

Resources