문제

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();

                }
            }
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top