views:

93

answers:

1

I have a program that generates a PDF as output. If I send this file to a printer using the Adobe viewer, it prints exactly as wanted. In particular, the application is printing labels and there's a requirement that every last pixel on the page is used, i.e. no margins whatsoever.

I'd like to try and automate this process. GhostScript seemed a logical choice. I used the command lines

gs -dBATCH -dNOPAUSE -sDEVICE=psmono -sOutputFile=A4_300.xxx -sPAPERSIZE=a4 A4_Print.pdf

... or alternatively

gs -dBATCH -dNOPAUSE -sDEVICE=ljetplus -sOutputFile=A4_300.xxx -sPAPERSIZE=a4 A4_Print.pdf

I can send the output file, A4_300.xxx, to the printer via LPR and it almost prints well, but there's about 6-8 mm missing on all sides, i.e. there's a margin being enforced, and the text that should be printing in that area is actually being cut off.

Paper size should be a4, and that much is working correctly. But how can I arrange for the output to fill the whole page?

The output device is "some kind of HP laser printer"; I haven't seen the physical device. A similar printer I tested with was able to process output both for "psmono" (that produced PostScript) and "ljetplus" (binary, but printable).

Any advice, please?

+1  A: 
pipitas
This sounds like good advice, thank you very much! However... the Java software producing the output (and lpr) will ultimately be running on a Linux machine I'm unable to change the configuration of. If I can't get at the PPDs, is there something I can do with the file that's going to lpr? Any options I can pass to lpr?
Carl Smotricz
If its important that your application prints "to the last pixel" on a certain printer, it **requires** some level of control over that print queue (driver used as well as settings). Otherwise, forget it.
pipitas
Ubuntu is using CUPS for printing. If your PCL output from Ghostscript fulfills 2 conditions: (1) it is at all printable on the target printer; (2) it contains the PCL page image in exactly the required size -- then you could send it with the `-o raw=true` option, bypassing the CUPS filtering chain and shunning the PPD option injection by CUPS into the print data stream. (`lpr -p yourprintername -o raw=true /path/to/A4_300.xxx` -- you may as well use `lp -p...`, btw...)
pipitas
Does Adobe PDF viewer bypass the lpd then? Can I do the same? I'd be fine fiddling with bytes being sent to /dev/lpN, but these seem to be networked printers and I have no idea how they're connected. The internals of CUPS are a mystery to me that I'd rather not have to explore.
Carl Smotricz
I suspect the PCL would be good to go if I got it through unmangled, so I'll definitely be giving `-o raw=true` a shot. Heh, what's the use of having GS create printer-specific output if I'm gonna let the printer driver fiddle with it?
Carl Smotricz
It's been a looooong time since I've used Linux at all, let alone a recent AcroRead on Linux. It's not ruled out that Adobe bypasses the print system (very likely CUPS in this case, not LPD), but I think that is unlikely. Since they need to direct their print output from Reader (which will definitely be PostScript, not PCL) to one of the system's print queues, the way they could do it is by adding the `-o raw=true` or `-oraw` or `-o raw` somewhere to their print command. [And even more unlikely is that you used a PDF-consuming printer, which Reader auto-detected and fed with raw PDF...]
pipitas
GS is **NOT** creating printer-specific output. It's creating generic output. What's dubbed "printer-specific" usually includes fine-tuning commands to staple the output, draw paper from a certain tray, fold the sheets, and what-not. Such special features usually will only work for a specific model, once they're part of the print data stream. Ghostscript doesn't do that (not with the gs commands outlined above). Instead it creates a generic borderless PCL page image -- but in your special case this is what matches your requirements exactly, since you don't need my mentioned bells'n'whistles.
pipitas
Still struggling with this stuff, but I got a wealth of useful info from you, so here's my acceptance. Thank you!
Carl Smotricz