We have developed an in-house printing solution that allows users to manage their prints (audit/merge/review/send to multiple printers) etc... but we are having issues with the very end of the process - the final print.
Currently our solution stores documents (original & after merging) in PDFs. We need to be able to send these documents to a particular printer and have it in some cases (when the user has selected the option) print page 1 to tray 8 and the rest to tray 1. We can't split the PDFs and print them separately as they also have to be stapled by the printer as a single job.
Our idea was to convert the PDF files to PostScript files using ghostscript then insert PJL commands into the PostScript and then print this modified PostScript file using gsprint.
Unfortunately the combination of ghostscript, postscript, PJL and gsprint doesn't seem to be working. The PJL commands we try, which we CAN get to work within text files sent to the printer via the windows copy command, don't seem to have the same affect when put into the PostScript files and printed using gsprint.
Can anyone spot any hideous flaws in what we are doing to the PostScript or have any idea why the PostScript->PJL amends->gsprint workflow we have might not be working?
It's been very difficult to find examples online so it's very possible our placement of PJL commands is incorrect.
(//comments not in final file)
<ESC>%-12345X@PJL JOB<ESC>&l8H //start job printing first page
@PJL ENTER LANGUAGE = Postscript //to tray 8 (letterhead)
@PJL COMMENT CANPJL SET STAPLE=ONEUPLEFT //indicate the document should be stapled
%!PS-Adobe-3.0 //start of PostScript file proper
---
%%PageTrailer //end of first page
<ESC>%-12345X@PJL EOJ<ESC>%-12345X //end the first job
%%Page: 2
<ESC>%-12345X@PJL JOB<ESC>&l7H //start 2nd job to print remaining
--- //pages to tray 1 (plain)
---
%%EOF
<ESC>%-12345X@PJL EOJ<ESC>%-12345X //end 2nd job
We then take this modified PostScript and use gsprint as follows:
gsprint -noquery -ghostscript gswin32c -printer "printer" "C:\postscriptfile.ps"
This all print out to the default tray and unstapled, i.e. none of this works as expected.
I hope it's clear what we are trying to achieve. Any help would be greatly appreciated.
Thanks in advance.
PS: All our printers are Canon printers.
Edit:
After KenS's answer below it seems the logical workflow should instead be PDF->PCL->add PJL->send to printer with "copy"
Unfortunately we are still having issues with this, certain PJL commands seem to be ignored by our printers (the printers are definitely PCL printers).
If we take a 2 page PDF produced by Microsoft Word, convert it to PCL using ghostscript then edit that PCL file with Notepad++ add add the following:
<ESC>%-12345X@PJL JOB NAME = "My Print Job Name"<CR><LF>
@PJL SET DUPLEX = ON
@PJL SET OUTBIN = LOWER
@PJL ENTER LANGUAGE = PCL
...original PCL data...
<ESC>%-12345X@PJL EOJ<CR><LF>
<ESC>%-12345X
the document comes out of the lower output tray but not duplexed. But what is extra odd is that the printer seems to take much longer to print when DUPLEX = ON than the exact same job with DUPLEX = OFF and it sounds like it's doing something different internally.
Any ideas?
We had similar issue this is how we did using ghost script and PJL
http://reddymails.blogspot.com/2014/07/how-to-print-documents-using-java-how.html
Also bfo.com has some commercial jars which do the same thing without ghost script and in a Pure java way. But you have to pay for it :)