0

I tried below ghostscript command to print pdf with landscape orientation over network printer but got portrait printout. Please help me to find out solution.

GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(new Version(0, 0, 0), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "gsdll32.dll"), string.Empty, GhostscriptLicense.GPL);
Ghostscript.NET.Processor.GhostscriptProcessor processor = new Ghostscript.NET.Processor.GhostscriptProcessor(gvi, true);
List<string> switches = new List<string>();
switches.Add("-empty");
switches.Add("-dPrinted");
switches.Add("-dBATCH");
switches.Add("-dNOPAUSE");
switches.Add("-dNOSAFER");
switches.Add("-dNOPROMPT");               
switches.Add("-dPDFFitPage");  
switches.Add("-dNumCopies=" + copies.ToString());
switches.Add("-sDEVICE=mswinpr2");
switches.Add(Convert.ToString("-sOutputFile=%printer%") + printer);
switches.Add("-c");
switches.Add("<</Orientation 3>> setpagedevice");
switches.Add("-f");
switches.Add(pdfFileName);

processor.StartProcessing(switches.ToArray(), null);   
Raju Padhara
  • 687
  • 1
  • 7
  • 20
  • What do you mean by 'not work' ? Do you get an error, incorrect outpu, unexpected output, something else ? Where is an example file for us to look at ? A number of the command line switches you are using (eg /AutoRotatePages) have no effect with the mswinpr2 device, and a number of others (eg /Orientation) have no effect when the input is a PDF file rather than PostScript. You 'probably' want to set FIXEDMEDIA and a specific media e set PDFFitPagesize, and then set PDFFitPage, but its impossible to say without seeing an example. – KenS Jun 04 '16 at 07:51
  • @KenS, thank you very much for your comment. I updated print command in question. I do not get any error message using above command to print pdf over printer. Actually it prints pdf but orientation not changed. I want to print pdf with landscape orientation. – Raju Padhara Jun 06 '16 at 09:56
  • Hmm.... does your printer have landscape media ? If so you will have to select that media as the default for the printer before you print to it (at least I believe this is the case). PDFFitPage will orient the output so that it best fits on the media, so if you have portrait paper selected, then PDFFitPage will rotate the contents (ignoring other instructions) to portrait. One way to deal with this is to set the media size by using -dFIXEDMEDIA and -dDEVICEHIGHTPOINTS and -dDEVICEWIDTHPOINTS to set a specific, fixed, media size. Then doing PDFFitPage will fit the content to that size of paper. – KenS Jun 06 '16 at 11:31
  • @KenS, It works after giving media size. Please post your answer so i will accept it. Thank you very much :) – Raju Padhara Jun 06 '16 at 11:52
  • You're more than welcome, I'm pleased its working – KenS Jun 06 '16 at 15:47

1 Answers1

0

PDFFitPage will orient the output so that it best fits on the media, so if you have portrait paper selected, then PDFFitPage will rotate the contents (ignoring other instructions) to portrait.

One way to deal with this is to set the media size by using -dFIXEDMEDIA and -dDEVICEHIGHTPOINTS and -dDEVICEWIDTHPOINTS to set a specific, fixed, media size. Then doing PDFFitPage will fit the content to that size of paper

KenS
  • 30,202
  • 3
  • 34
  • 51