0
votes

How can I create 2 pdf files at the same time using GhostScript?

this is my code:

string gsPath = @"C:\Program Files (x86)\gs\gs9.26\bin\gswin32.exe";

                List gsArgsList = new List();
                gsArgsList.Add(" -dPDFA=2");
                gsArgsList.Add(" -dBATCH");
                gsArgsList.Add(" -dNOPAUSE");                
                gsArgsList.Add(" -sProcessColorModel=DeviceCMYK");
                gsArgsList.Add(" -sDEVICE=pdfwrite");
                gsArgsList.Add(" -dPDFACompatibilityPolicy=1");
                gsArgsList.Add(" -sOutputFile=" + nuevo);
                gsArgsList.Add(" " + rutaPdfNormal); 

                var gsArgs = String.Join(null, gsArgsList);

                string gs = gsPath + gsArgs;
                System.Diagnostics.Process.Start(gsPath, gsArgs);
1
You could create two threads (using Tasks) which are both generating PDFs - ADyson
I want to do it with a single invocation to ghostscript - jonathan
why do you care about that? - ADyson
P.S. To clarify, by "at once" do you mean "in parallel, simultaneously", or just "one after the other without issuing more commands"? - ADyson
in parallel, simultaneously - jonathan

1 Answers

1
votes

You cannot create two PDF files simultaneously in a single instance of Ghostscript. The pdfwrite device (which writes the PDF file) only writes to a single file.

I also cannot see the point in writing two files at the same time; perhaps if you explained what you were trying to achieve it might be possible to advise further.

The example you linked to above isn't writing two PDF files simultaneously. It starts by writing to the output file 'tiger.pdf' running the input file 'tiger.eps'. Then it switches to the output file 'colorcir.pdf' and runs the file 'colorcir.ps'. That's not simultaneous, it's sequential; it's exactly the same as running Ghostscript twice with different command lines.