1 Replies - 160 Views - Last Post: 19 November 2019 - 07:15 AM Rate Topic: -----

#1 KC10513   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 29
  • Joined: 13-October 17

Ghostscript PDF Black&White and Page range

Posted 19 November 2019 - 02:50 AM

I'm coding a PDF printer that will be running on a server. Basically i have a pdf file(color or black and white) that is already created then we tell ghostscript to send the file to a physical printer and the output should either be b&w/color based on the parameters selected + many other fields we can set such as page range, number of copies etc...
here's the method i use but am failing to print b&w and also setting the page range
public static void printPDF(string filename, string printerName, int numberofcopies, bool pagerange, int frompage, int topage)
                using (GhostscriptProcessor processor = new GhostscriptProcessor())
                    List<string> switches = new List<string>();
                    if (pagerange)
                        switches.Add("-sPageList=" + frompage + "-" + topage);
                    switches.Add("-dNumCopies=" + numberofcopies);
                    //switches.Add(Convert.ToString("-sOutputFile=%printer%") + printerName);
                    switches.Add(@"-sOutputFile=""%printer%" + printerName + "\"");
                    switches.Add(" - f");
                    processor.Process(switches.ToArray(), null);
            catch (Exception ex)
                throw ex;

So i ask is there something wrong with my code or am i missing a switch somewhere.

Is This A Good Question/Topic? 0
  • +

Replies To: Ghostscript PDF Black&White and Page range

#2 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7139
  • View blog
  • Posts: 24,245
  • Joined: 05-May 12

Re: Ghostscript PDF Black&White and Page range

Posted 19 November 2019 - 07:15 AM

From the C# perspective, nothing looks wrong there.

From the GhostScript perspective, I have no idea.

Your question above is essentially a "how to use GhostScript" question rather than a C# question.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1