Google Cloud Print with TSP100 variable length document - printing

I currently have the following issue. I would like to print a receipt (pdf file) on a Star TSP100 thermal printer with Google Cloud Print (from AppEngine). The connection works great, but I have an issue with the positioning.
The PDF file has a variable length, and therefore I have to print the document on 72mm x 2000mm (so the length is always correct). The remaining whitespace is cut off by the printer. When I print a receipt with the default print dialog in Chrome, the document is positioned at the top of the canvas (72mm x 2000mm). However, when I try to print the same document with Google Cloud Print the document is positioned at the center of the canvas. The result is a lot of whitespace before the actual receipt starts. The whitespace after is still cut off correctly by the printer.
Things I tried so far:
Setting a specific media size in the Cloud Job Ticket (CJT). Then the printer cuts off at 200mm length (default printer setting).
Posting a printjob from Chrome and checking the CJT of this job in the GCP Simulation API. The CJT is not different from mine, so how is Chrome able to print a different document?
All other options in the CJT as described in the Google Cloud Print Documentation.
Banging my head against the wall, also didn't work.
If I could mimic a request from Chrome (which gives the correct result), the problem would be solved. However, I can not see how these are different from my requests.
Any help is greatly appreciated!

Related

How to print same document with different printer at the same time

I have a docx document with thousands of pages. I also have 3 printers with same brand and type attached to my PC. I want to print page 1-1000 using printer1, page 1001-2000 using printer2 and page 2001-3000 using printer3. I'm unable to print those pages at the same time. It prints sequentially not simultaneously. I also change Enable printer pooling but no luck so far.

google cloud print tray media size

I read the GCP documentation, I managed to grab in the google drive folder the documents I need to print every day before the guys enter the office, these docs are pdf in A5 format, I have the second tray filled with A5 paper.
By the GCP interface i can print all of them selecting A5 format (not the tray) and they are printed accordingly, using the script amended with the width and length size (148000 and 210000 in microns) I obtain the doc printed in A5 format on the A4 paper, I tried to change the tray paper but the printer got error ( Kyocera ).
I searched all the web looking for some info regarding how to set the tray, on the same GCP docs and also here in a question, I understand that I could grab printer capabilities by using /printer service, I think that in there I could read how to amend the ticket and selecting the tray if it would be possible. I do not understand how to use /printer service, any suggestion on how to get it?
Although you can retrieve the printer's input trays by checking the InputTrayUnit attribute in the PrinterDescriptionSection of the Cloud Device Description, it is not possible to set this information in a job ticket: There's no way to set the tray in the PrintTicketSection of the Cloud Job Ticket

Communicate with and control a printer device via bluetooth or USB

The device is a label printer. It can be connected to via bluetooth and USB. I would imagine it is running some kind of linux, as it has a fairly complex interface/screen, but am not sure. In fact, this is something I would like to determine. But my goal is to get a shell, or some kind of 'meaningful' connection through which I can send commands/data which will trigger print events by the printer without using the manufacturer's software
Connecting to the device in ubuntu via USB creates /dev/usb/lp0. I tried connecting to this using python's serial module, but it couldn't connect to the serial port.
Via bluetooth I was also able to connect, using hcitool scan to get the device's MAC address and then rfcomm to connect (using this approach) . This created /dev/rfcomm0, which I was able to connect to and send data to using python.
Is it feasible to mimic the data normally sent over usb/bluetooth by the manufacturer's software to print without the software? I assume getting this would be possible by 'sniffing' data sent over bluetooth while a normal print command is sent by the manufacturer's software (although I suppose there's no reason it would look intelligible to a human).
If this kind of mimicry is possible, I am wondering whether simply sending the equivalent data over bluetooth, for example, would result in a print event. So far I have no reason to believe that data I send via the bluetooth connection is not being received, but I have yet to get any kind of response (data or physical) from the bluetooth connection.
Any advice/suggestions on how I might achieve my overall goal would be appreciated
This is certainly possible (sorry for the answer 6 years later, but hopefully this will help anyone later in need). I have a similar problem and this is how I solved.
I have a MHT-P80F thermo printer. I figured out in settings that it supports a protocol called TSPL. These are the instructions you need to send to a printer and tell it to do either raw text printing, or even bitmaps.
All you need to do is to construct the correct bytestream (in mostly human-readable ASCII) and send it to /dev/usb/lp0. I have not tested it via bluetooth but I assume it should be similar.
For example, if you want to print out a "Hello World", these instructions will suffice:
CLS
SIZE 80mm,50mm
GAP 5mm,0mm
HOME
TEXT 0,0,"0",0,1,1,"Hello World"
PRINT 1
Each line is separated by a "\n".
Explanations (more could be found by searching TSPL):
CLS Tell the printer to clear all previous staged commands.
SIZE Tell the printer the size of each label (width, height).
GAP Between each label there's 5mm space without paper.
HOME (Re-)locate the paper roll for a new print.
PRINT Start printing of 1 copie(s).
Note these instructions are for the use of discrete labels. For a whole paper roll it might be different. TSPL implementations on different printers may differ, so you might to experiment a bit.
Generally, if you can print a bitmap, then you can print virtually any document (e.g. using PIL in Python or Jimp in Node.js to generate an image beforehand). So here's the most useful BITMAP command:
BITMAP 16,24,40,256,0,<BYTE STREAM>
where
16: the starting (left most) X coordinate for your bitmap
24: the starting (top most) Y coordinate for your bitmap
40: the width of bitmap, in BYTES (see below)
256: the height of bitmap, in DOTS
0: mode of print, 0 being overwritting anything in that region
and <BYTESTREAM> being the binary data(black/white) of this image, from left to right and from top to bottom.
The bitmap width is given in bytes, so each byte represents 8 horizontal continous dots in the image. The highest bit 7 being most left, the lowest bit 0 most right. So if as in example we write 40 in this parameter, the image would be 40x8=320 dots in width.
The bitmap height, on the contray, is given in dots.
Most such thermal printer have a DPI of 203. This is an interesting start point to investigate into: 203/25.4 = 7.99, or rounded as 8. So for the printer, each 8 dots equals 1mm. In the above example, X=16 and Y=24 (both in dots) corresponds to starting location X=2mm and Y=3mm.
And finally, you generally do not need to inverse the color of this image. In BITMAP command, a 1 in a bit means correctly white or non-printed dot, and 0 means the black or heated dot.
I am not sure about bluetooth but for USB printing you can use the cups library (licups) and use the APIs to do the priting. It uses IPP protocol. Usually cups uses a .ppd file specific to the printer (which contains the details about the printer) for installing it. For new language versions such as PCL5, 5e, 6 etc there are generic ppd files that can be used to install any printer that uses the respective language

PCL: printing out partial page without ejecting

I want to be able to make my printer (HP DeskJet 1280 on USB) print out all raster data I have sent to it so far, without ejecting the page. I am sending only plain raster graphics and cursor positioning commands — no vector graphics, no text.
More precisely, I have two questions:
1) After sending some raster data to the printer (with Transfer Raster Data ("\033*b%dW")), how to make it print it out right away and stop, without ejecting the page?
2) After sending a vertical cursor positioning command with a positive argument (e.g., Vertical Cursor Positioning (Decipoints) ("\033&a%+dV")), how to make the printer advance the paper to the new position right away and stop there?
(Note that even solving only (1) would be almost sufficient, because advancing the cursor could be done indirectly by sending a blank raster of the appropriate height.)
Since PCL is a page description language, it could be actually impossible to do things at such a low level. But after an extensive search in the PCL documentation and the Internet, I have not yet found a definite negative answer either.
It seems that the printer has some kind of internal buffer to store its data, and that it flushes (i.e., prints out) that buffer when it grows large enough. If there were a command to tell the printer to flush that buffer immediately without doing anything else, everything would be fine. But I have not found such a command. Even "\033*rC" (End Raster Graphics) has no immediate effect.
I am using CUPS' USB backend to communicate with the printer, and have verified (using usbmon) that the backend actually sends all my commands to the printer as soon as it sees them, so it cannot be the issue of data getting stuck in the driver.
Commands that print out partial pages include, for example, "\033E" (Printer Reset), "\033%%-12345X" (Universal Exit Language), "\033&r1F" (Flush All Pages (including partial pages)) — but all of them also eject the partial page.
Can somebody suggest a clever way to do what I want, or confirm my impression that it is an absolute impossibility?

Automatic printing from web app

I am writing a web app that needs to quickly print a name tag and a parent claim check as we check children in. I am using a Dymo Twin Turbo (a label print that can have 1 label type on the left and a different sized label on the right). When I check in a child, it needs to print one on each side of the printer without prompting. I have found jZebra (which I am still trying to figure out) but it doesn't seem to have the capability to choose which tray it will print to. Is there another applet or such that would be better, or is there something about jZebra that I could use?
If anyone is interested in what I came up with: Dymo has a great JavaScript framework that works with its label writers. This framework can be found in the developers section of the Dymo website (http://developers.dymo.com/). The examples provided all use a button to print, instead I used an onLoad event to call my function. It was my first real attempt at JavaScript, so it took me a while to get it working like I wanted, but it works great!

Resources