Ghostscript output to file with ESC-P sequences - printing

For a project (printing nanofluids with an Epson printer) I want to see the the code that the computer sends to the printer. I am running Ubuntu 16.04 and have an Epson Stylus SX600FW printer.
Using Ghostscript 9.18 I am trying to print a simple file test.ps and I want to obtain the output file that is being send to the printer. This file should contain some ESC/P sequences if I am right.
I tried to obtain such a file using:
gs -sDevice=epson -sOutputFile=test1output test1.ps
Whatever I try, I can't find the output file anywhere, so I doubt it is even created. Then next if I have the output file, how can I read the ESC/P sequences? Thanks in advance!

For me, that command line results in a file called 'test1output' in the current directory. If you are unable to find the file you could try specifying a complete path and file spec, or at least -sOutputFile=./test1output
As for reading the sequences, any binary editor will read the file.

Related

Modify basic files used with gwbasic

I have a batch file which launches other .bas files with the help of gwbasic.
Here is the code of the batch file:
graphics
cd basic
gwbasic menut-hp/d
cd \
Then I have the possibility by typing 1 or 2 etc + ENTER to choose which program i want to run. The programs are located in the same directory as my batch file. The programs are xxx.BAS files.
The problem is:
I have a piece of software written in GWBASIC that currently is set up to just print locally to LPT1.
When I disconnect the local printer, the software (gwbasic i guess) sends automatically the things to print to the network printer.
The result is that a lot of A4 papers come out with only a few lines written.
On the local printer, the printer only printed when i exited the batch program.
On the network printer, it's like its non stop synchronizing, and not only when i exit the batch program.
I see 2 solutions:
manage to put a tempo for the printing on the network printer (to refresh every 2 minutes for example)
or try to add a line in the .BAS files, to save the text in a .txt of .pdf file, instead of printing it.. or print it in a pdf file.
I have almost no idea how gwbasic works, even after some researches.
Moreover, i haven't managed to view (and modify) the code of the .BAS files
Sorry for my bad english,
If anyone has any idea, it would help me a lot!
Thank you very much :)
Maybe later, but I enjoy scripting with BASIC and CONSOLE APP.
I recommend you run a command BAT before you BAS code to get default printer
wmic printer get name,default | find "TRUE" > Printer.txt
With this linen you get the similar response into Printer.txt
TRUE Microsoft Print to PDF
After that, in your BAS code, read them and validate printer name or discard network printer before print.
Happy coding!

LPR: what is the location of the file that will be sent to the printer?

For a research project about printing nanofluids I need some more control over my Epson Stylus SX600FW.
I am sending a file to the printer using lpr test.ps, then it is in the print queue. Now I want to see the file (in pdl?) that the printer driver will send to the printer. Where is the temp storage location of this file?
Or is there any other way to obtain this file? This file should contain ESC/P-R sequences in which I want to make some changes and then send that file to the printer.
Using the URI file:/tmp/ouput.prn, and by configuring it with the (gimpprint) driver of your printer, you can obtain the output that is being sent to the printer.
This is a hexadecimal file. Using the parse-escp2 perl script from the test directory of gimp-print you can view this file in a bit more understandable format.

Conversion between EPL and ZPL

Is it possible to convert EPL and ZPL (thermal printer languages) to common format (it could be vector grapic file like SVG)?
It will be great if I could convert from commont format to ZPL or EPL.
If you do any amount of work with Zebra thermal printers, get a design tool. The FREE ZebraDesigner2 software will do. This way you can export your printer based on whatever printer driver you have selected (EPL/ZPL/CPCL). If you need to export code for non-Zebra printers (Sato, Datamax, Intermec) look at NiceLabel
Once you have ZebraDesigner installed and driver selected, create a new port mapped to a location on your hard drive with write privileges. Then print the label and the driver will create a txt file with the printer code.
Use the printer code in your application as needed.
Not really, but I have sent WordPad docs (not WORD or .txt) to the printer and let the print driver do the work. I think I even was able to change a plain old .txt file extension to .rtf and gotten it to print sending it to the printer (copy file to UNC share path of printer). Not sure that is exactly what you were asking but I hope it helps.
Sometimes you just gotta play with these zebras and see what they will do.
If you are using linux, you can install rastertoezpl CUPS Printer Driver, so you can print any raster image (jpg, png, bmp etc., possible non image filetypes too) via thermal transfer printer.
Quick installation guide (possible I've omitted something):
tar xzf rastertoezpl-1.0.6.tar.gz
cd rastertoezpl-1.0.6
sudo aptitude install libcupsppdc1-dev libcupsimage2-dev libcupsfilters-dev libcups2-dev cups-ppdc cups checkinstall gcc checkinstall
sudo ./configure
sudo checkinstall
press '10' (Required) -> cups, cups-ppdc, libcups2, libcupsimage2, libcupsppdc1, libcupsfilters1
Then you have to setup the printer in localhost:631/printers/
Verbose installation guide for Ubuntu (russian)
Works fine for me, now I'm looking for .ezp -> raster converter...

File format of spool files with .tmp extensions?

In many Windows setups, when you print directly to a printer, two files are typically created in the windows spool directory "C:\Windows\System32\spool\PRINTERS". A spool file "80021.SPL" and a shadow file "80021.SHD" are examples of these files. The spool file contains the meat and potatoes of the drawing instructions so the printer can print the page. The data in this spool file comes in a smorgasbord of different formats depending on the language technology and the print driver used. However, when you are printing to a printer that's on a print server, a single ".TMP" file is created instead and gets transmitted to the print server. I think its fair to assume that this is just the .SHD and .SPL files combined into a single transport file to get it to the server. However, its unreadable, i'm nto sure if its zipped, encrypted, or what, but I can't decipher it. When printing PDFs you can typically see plain text PostScript instructions in the spool file (.SPL), by just opening it and viewing it in a text editor. You can even send that spool file (.SPL) to a postscript viewer like GhostScript and have it show you the pages drawn on screen. But when the job is all packaged up in a .TMP file, its basically just a binary pile of bits. Does anyone know how to uncompress the data from these transport .TMP spool files?
I believe that file you have will be an EMF file that is padded with a proprietary MS structure at the beginning. Easiest way to find out if you are dealing with an EMF structure is to look for the ANSI characters ' EMF' in tmp file you have.
Assuming that you do find these characters it is just a matter of removing the proprietary structure data from the beginning of the file then treating it as a standard EMF file. Fortunately all EMF files have a standard header format so it should be reasonably to determine where the EMF file starts.
There is a good description of EMF file headers here

Convert a text file with Embedded HP Printer Codes to PostScript

I have an application that prints by generating text files with embedded printer codes, then basically just copies the file to the printer to print. I need to take that print file and convert it to an image - just as if it was printed then scanned.
My first thought was to setup a printer with a postscript printer driver attached to a file port, and then run the result through ghostscript to create a tiff, but it isn't working.
Any ideas?
The printer codes are probably PCL. Maybe pcl-parser could serve as a start for your own tool to do this? There also seems to be a commercial product called PCLXForm.
Edit: Also investigate GhostPCL.

Resources