zippy1978 / ghost4j

Java wrapper for Ghostscript C API + PS/PDF document handling API
http://www.ghost4j.org
GNU Lesser General Public License v3.0
64 stars 39 forks source link

setpagedevice #16

Closed jiganet closed 10 years ago

jiganet commented 11 years ago

God day, I have question regarding the setpagedevice command.

We build PostScript files with specific setpagedevice commands.

We have a process where we have to do a ps2ps in order to attach some images to the PostScript file. When you do this, the setpagedevice parameters are lost, that's why we have to add them again.

When using Ghost4j we start using the same approach, ps2ps, then add the setpagedevice and a special command for kyocera that give us the power to select the paper tray ej:

<< /NumCopies Ncopias /ManualFeed false /DeferredMediaSelection false>> setpagedevice statusdict begin 0 setpapertray end

Take notice of the code after the setpagedevice "statusdict begin 0 setpapertray end"

When we use the Ghost4j and correctly made the PS file with ps2ps, the document works well, but when the file goes to the printer, the parameters gets override.

We see that the file has an override to setpagedevice and the values set to the statusdict specifically to /papertray with setpapertray are of no use. After doing the ps2ps and then appending the line of code for the pagedevice and the papertray at the top of the file, the commands appear to do nothing in the printer side.

I think that every execution of the "GS_pswrite_2_0_1001" for every page, overrides the command of the paper tray. ¿Is this assumption correct?

¿What can I do to prevent this?

Thank you.

jiganet commented 11 years ago

Another thing:

When I use this command:

        String[] gsArgs = new String[9];
        gsArgs[0] = "-psconv";
        gsArgs[1] = "-dNOPAUSE";
        gsArgs[2] = "-dBATCH";
        gsArgs[3] = "-dNOSAFER";
        gsArgs[4] = "-sDEVICE=pswrite";
        gsArgs[5] = "-sOutputFile="+ archivoFinalConFoto.toString();
        gsArgs[6] = "-c";
        gsArgs[7] = "statusdict begin 2 setpapertray end";
        gsArgs[8] = "-f" + rutaDatos;

And then check the resulting file, after it executes, I issue this command to check what is the value of the "papertray": "statusdict /papertray get" the spected result should be 2, but the actual result is 1. So the command has no effect.

zippy1978 commented 11 years ago

Hi, I'm not sure but did you have a look at the Adobe DSC to know where to put your setpagedevice call ?

jiganet commented 11 years ago

This file is generated by using "-sDEVICE=pswrite"

captura

What concerns my is that I used to do the same with the "ps2ps.bat -dNOSAFER input.ps output.ps" when using this command, we have absolute control of the device (Printer) but with this options:

  String[] gsArgs = new String[9];
    gsArgs[0] = "-psconv";
    gsArgs[1] = "-dNOPAUSE";
    gsArgs[2] = "-dBATCH";
    gsArgs[3] = "-dNOSAFER";
    gsArgs[4] = "-sDEVICE=pswrite";
    gsArgs[5] = "-sOutputFile="+ archivoFinalConFoto.toString();
    gsArgs[6] = "-c";
    gsArgs[7] = "statusdict begin 2 setpapertray end";
    gsArgs[8] = "-f" + rutaDatos;

we loose control, not in all aspects, we can actually control what lays inside the setpagedevice like "/Duplex" but we cannot set the paper tray.

Is there such a big difference between the two commands?

Mean while we are testing with different printers and configurations to see if we can make it print from the correct paper tray using "statement".

Thank you for your response by the way.

zippy1978 commented 11 years ago

Hi

Ghost4J directly sends args to Ghostscript : so it should behave the same... And I don't think I really understand what you mean : is the command ignored ? Do you get an error ? Is it a matter of printer not behaving as expected ?

Regards Gilles