开发者

Fine-tuning ghostscript PDF to PS conversion

开发者 https://www.devze.com 2023-01-10 01:54 出处:网络
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 pr开发者_如何学Cinting labels a

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 pr开发者_如何学Cinting 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?


First of all: are you sure that your printer is physically able to print edge-to-edge? Which printer model is it?

It may well be that the printer itself enforces the "missing 6-8 mm on all sides". Since you see the margin "area actually being cut off", it means the printer indeed receives the complete image, but it crops the image to what appears as *ImageableArea keywords in PostScript printer PPDs (PS Printer Description files).

If your printer supports edge-to-edge printing indeed, then you may need to enable it as a default...

  • ...by some semi-secret setting in the front panel menu (if your printer has s.th. like that), or...
  • ...by accessing the web-based printer configuration panel from your computer's browser (should your printer support that), or...
  • ...by logging into the printer via telnet, rsh, ssh or msh (depending on your printer to allow this).

The actual procedure to set this depends on your printer model. It should be described in the printer manual.

If you are unlucky, the device simply doesn't support borderless printing. Then buy or find a model that does what you want ;-)


Update: I had missed your statement "If I send this file to a printer using the Adobe viewer, it prints exactly as wanted." From this I conclude that your printer must indeed be supporting borderless printing.

If your LPR client uses any form of PPD (as is the case if you print via CUPS, f.e.), then check out my hints about modifying PPDs (which also works for Windows systems) here:

  • "What lpr arguments do I need to print a 1400x800 pixel image on a 4x6 label?"
  • "What's the easiest way to add custom page sizes to a PPD?"

Most likely you do not need to finetune your Ghostscript output; it is fine as the cropped printouts show.

Most likely you need to tweak your LPR client so that its "driver" does not destroy what you want to send to the printer.

0

精彩评论

暂无评论...
验证码 换一张
取 消