0

We use have an winform app, which uses AdobeReader to print files from a specific directory. Recently, we re-factored this app whereby replacing AdobeReader with Ghost script. AdobeReader prints document properly (as per document format such as font, alignment, line spacing etc). But Ghost script print the document without complying the document format. Any advise ?

FYI: PrintParamter is a custom type which enclose the details of file name/path to print, GetDefaultPrinter() is a helper method which return default printer.

private void PrintDocument(PrintParamter fs, string printerName = null, bool isPortrait = true,
                                   int noOfCopies = 1, bool printInGrey = false)
        {
            var filename = fs.FullyQualifiedName ?? string.Empty;
            printerName = printerName ?? GetDefaultPrinter();
            var processArgs = string.Format("-noquery {0}  -dNumCopies={1} -all {4} -printer \"{2}\" \"{3}\"",
                                            isPortrait ? "-portrait" : "-landscape", noOfCopies != 1 ? noOfCopies : 1,
                                            printerName, filename, printInGrey ? "-grey" : "-colour");
            try
            {

                var gsProcessInfo = new ProcessStartInfo
                                        {
                                            WindowStyle = ProcessWindowStyle.Hidden,
                                            FileName = _ghostScriptLocation,
                                            Arguments = processArgs
                                        };
                using (var gsProcess = Process.Start(gsProcessInfo))
                {
                   gsProcess.WaitForExit();

                }
            }
S.N
  • 4,910
  • 5
  • 31
  • 51
  • What Ghostscript command line are you using ? What version of Ghostscript are you using ? Where can we download a specimen file to examine ? – KenS Dec 03 '13 at 16:05
  • To answer your questions. (1) see the processArgs, which mentioned in the original thread (2) I am using 5.0 (3) You can have a flavor of the Ghost script from the gien URL. see the original thread. Thanks – S.N Dec 03 '13 at 16:52
  • OK, the processAgrs is more or less useless. It doesn't make sense for Ghostscript and its a bunch of variables, I've got no idea what you put in there. Ghostscript 5.0 is ancient, possibly you mean you are using GSView 5.0 (which might explain the processArgs) in which case the question remains, which version of Ghostscript are you using ? The URL points to the University of Wisconsin web site which is now unused. You still haven't given a specimen file to reproduce the problem. – KenS Dec 03 '13 at 17:56

1 Answers1

0

Just to update, We have gave-up the Ghostscript approach and deiced to use iTextSharp to grab the document instance and print it. Technically, the iTextSharp doesn't manipulate the document but wrap it before printing.

S.N
  • 4,910
  • 5
  • 31
  • 51