Reputation: 213
Sorry I am very new to Ghostscript and the whole postscript language.
I have the following need:
I need to be able to extract a page from a specific PDF document, process this page in an external API that returns a postscript file (call it APIProcessedPS) with the same page. Once this is done I need to send everything to a printer but keeping the coherence of the whole document (i.e. not printing a part then another because the documents might not be assembled correctly on the printer if someone print goes between my two requests).
In addition I have some more challenges:
What I already know do to:
What I struggle with:
I would be very thankful if someone could give me some hints as to where to start.
I am trying the GS route because it seems the most reasonable, but I am very open to a different way for example using an external c# library or api if it fits the need.
Thanks
Pat
Upvotes: 0
Views: 304
Reputation: 31199
PostScript is a programming language, so you need to understand that what you are trying to do is meddle with a program, without breaking it. This is not trivial.
Fortunately for you the ps2write device, in recent versions of Ghostscript, produces what is called DSC (Document Structure Convention) PostScript. That means that each page in the output PostScript file is a separate entity. Provided you keep the initial prolog at the top, then you can rearrange the pages within the remainder of the program.
However, that doesn't mean you can necessarily insert a different PostScript program in the middle of the existing program without causing a problem. Your best bet is to do a save before inserting the new content, and a restore afterwards. Can't guarantee it, because I'd need to see the programs in each case.
Altering the colour of the content is not clear. Is this text, linework, images ? Some combination ? What colour space is it defined in ? Again you are talking about trying to modify a program, this is non-trivial. You would do better to have the external application get this right externally. Again without seeing the PostScript, it's pretty much impossible to comment.
Using different trays for pages is device-dependent, you need to find out what you need to send to the printer to have it use a different tray. Once you know that you can either insert the relevant commands yourself or use the PSDocOptions or PSPageOptions switches in Ghostscript to insert the required commands on the relevant page.
Upvotes: 0