Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ghostscript - PDF file, with multiple trays, and with a lot of problems

I don't speak good english, but I hope anyone can help me on this one...

I spent several days on this but I can't figure out on my own. Here's the deal:

I Have 4000+ PDF documents, with TrimBox margins, each one with 16 pages, color.

I needed to batch print them:

  • Print pages 1-10 using the paper on tray 3;
  • Print pages 11-15 using the paper on tray 4, two copies uncollated.
  • Print page 16 using the paper on tray 3.

I'm using an Kyocera 7550ci, the PPD is here.

I have installed GhostScript 9.19, and also gsview with gsprint. Windows 7 SP1.

When I first tried to do anything at all, didn't know ghostscript or how to use it, but doing some reading I managed to "kind of" solve the problem. I duplicated the printer on Windows control panel, setted each one with the configurations I wanted and did the following command on GSPRINT:

gsprint -printer "Kyocera TASKalfa 7550ci KX" -color -dUseTrimBox -dFitPage -from 1 -to 10 s_file0001.pdf
gsprint -printer "ALT Kyocera" -color -dUseTrimBox -dFitPage -from 11 -to 15  -copies 2 s_file0001.pdf
gsprint -printer "Kyocera TASKalfa 7550ci KX" -color -dUseTrimBox -dFitPage -from 16 -to 16 s_file0001.pdf

(I setted TASKalfa 7550ci default driver to use tray 3, and ALT Kyocera to use tray 4 and uncollate).

It worked, but was painfully slow both to Windows process, and the printer to process. I soon realised GSPRINT is slow because it has to render the whole image to bitmap, and started to see if I could use pure GhostScript to do the work.

gswin32c -dBATCH -dNOPAUSE -q -dUseTrimBox -dFitPage -dFirstPage=1 -dLastPage=10 -sDEVICE=mswinpr2 -sOutputFile="%printer%Kyocera TASKalfa 7550ci KX" -f test.pdf
gswin32c -dBATCH -dNOPAUSE -q -dUseTrimBox -dFitPage -dFirstPage=11 -dLastPage=15 -sDEVICE=mswinpr2 -sOutputFile="%printer%ALT Kyocera" -f test.pdf
gswin32c -dBATCH -dNOPAUSE -q -dUseTrimBox -dFitPage -dFirstPage=16 -dLastPage=16 -sDEVICE=mswinpr2 -sOutputFile="%printer%Kyocera TASKalfa 7550ci KX" -f test.pdf

But I'm still with alot of problems... I'm frustrated that I couldn't get it to work even trying really hard to read manuals and search around.

  • Using mswinpr2 is still really slow, gives me wrong colors, and can't figure out how to select the paper tray.
  • Using any included PCL drivers, altrought was fast and managed to select the correct tray using dMediaPosition, there's only Black and white drivers...
  • Using pdfwrite, don't correct scale the TrimBox to fit the whole page, and can't select correct tray.
  • Using ps2write, can't select tray and messes up with the page position.

I'm lost. someone can give me some directions? Also, there's some way to send everythign as one file to the printer?

Thank you ALL!

---EDIT---

Thank you both for the answers!

I managed to make it work:

gswin32c -dBATCH -dNOPAUSE -q -dPDFFitPage -dUseTrimBox -dFirstPage=1  -dLastPage=10 \
         -dMediaPosition=7 -sDEVICE=pxlcolor \
         -sOutputFile="%printer%Kyocera TASKalfa 7550ci KX" -f in.pdf

gswin32c -dBATCH -dNOPAUSE -q -dPDFFitPage -dUseTrimBox -dFirstPage=11 -dLastPage=15 \
         -dMediaPosition=5  -sDEVICE=pxlcolor -dNumCopies=2 \
         -sOutputFile="%printer%Kyocera TASKalfa 7550ci KX" -f in.pdf

gswin32c -dBATCH -dNOPAUSE -q -dPDFFitPage -dUseTrimBox -dFirstPage=16 -dLastPage=16 \
         -dMediaPosition=7 -sDEVICE=pxlcolor \
         -sOutputFile="%printer%Kyocera TASKalfa 7550ci KX" -f in.pdf

The only thing is that the page doesn't scale correctly on pxlcolor (it does on ljet4, but it's black and white).

I'm almost there! Thanks ^^. If anyone knows about this problem, I would appreciate.

like image 844
Johnny Blue Avatar asked Sep 03 '25 01:09

Johnny Blue


1 Answers

You have asked a lot of questions, all at once, that's not really a good way to get helpful answers. In addition you haven't really been too clear about some of the problems.

1) If you want to use the TrimBox for the media size then you have to tell Ghostscript you want to use the TrimBox, you do that by -dUseTrimBox, no matter what device you want to use.

2) The mswinpr2 device works by creating a Windows DeviceContext for the printer, rendering the input to a (RGB) bitmap, then blitting the bitmap to the DeviceContext and telling it to print itself. This is slow because it will involve rendering a large bitmap (size dependent on printer resolution) to memory and then sending that large bitmap to the device.

Its one great advantage is that it will work no matter what printer you have.

GSPrint uses a 'similar' but somewhat different technique and is claimed to be faster.

Note that both these devices use the default settings of the printer which probably won't work for your complex needs.

Colour management is, of course, up to Windows in this case, but if your original PDF is specified in say CMYK then this will involve conversions CMYK->RGB->CMYK which is bound to cause colour differences.

3) There are colour PCL devices available in Ghostscript, eg the cdeskjet device.

4) pdfwrite will use the TrimBox if you select -dUseTrimBox. Since it creates a PDF file its rather hard to see how it could 'select correct tray'. If you are sending the PDF file to the printer, then you could simply have started with the original PDF file. PDF files cannot contain device-dependent criteria, such as tray selection.

5) ps2write in its current incarnation will allow you to add device-specific operations, see ghostpdl/doc/VectorDevices.htm (also available on the ghostscript.com website), section 6.5 "PostScript file output" and look for the PSDocOptions and PSPageOptions keys. You could use the PSPageOptions array to introduce individual media selection commands to each page. I have no idea what you mean by 'messes up the page position', however yet again if you do not select -dUseTrimBox then it will not be using the TrimBox........

Oh, and if you want to 'scale the TrimBox to fit the whole page' (which you only mention regarding pdfwrite) then you will have to set up a fixed media of the size you want the page scaled to (-dFIXEDMEDIA, -dDEVICEHEIGHTPOINTS= and -dDEVICEWIDTHPOINTS=), select -dUseTrimBox and -dPDFFitPage.

like image 119
KenS Avatar answered Sep 06 '25 23:09

KenS