예제 #1
0
 protected override void DoRunInitialize(Ghostscript ghostscript)
 {
     // run the prolog if there is any
     if (_prologAndSetup != null)
     {
         ghostscript.Run(_prologAndSetup);
     }
 }
예제 #2
0
            protected override void DoRunInitialize(Ghostscript ghostscript)
            {
                // escape the path
                var escapedFileName = new StringBuilder(FilePath);

                for (var i = escapedFileName.Length - 1; i >= 0; i--)
                {
                    switch (escapedFileName[i])
                    {
                    case '(':
                    case ')':
                    case '\\':
                    {
                        escapedFileName.Insert(i, '\\');
                        break;
                    }
                    }
                }

                // load the PDF
                ghostscript.Run(string.Format(CultureInfo.InvariantCulture, "({0}) (r) file runpdfbegin process_trailer_attrs", escapedFileName));
            }
예제 #3
0
            protected override void DoConvert(ConvertFormat format, Action pageCompletedCallback, Func <bool> cancellationCallback)
            {
                // convert the file using Ghostscript
                var outputFile = format.SupportsSingleFile ? Path.ChangeExtension(FilePath, format.FileExtension) : Path.Combine(Path.GetDirectoryName(FilePath), new StringBuilder(Path.GetFileNameWithoutExtension(FilePath)).Append("_%d.").Append(format.FileExtension).ToString());

                using (var ghostscript = new Ghostscript(format.GetArguments(outputFile)))
                {
                    if (cancellationCallback != null)
                    {
                        ghostscript.Poll += (s, e) => e.Cancel = cancellationCallback();
                    }
                    if (format == ConvertFormat.Pdf)
                    {
                        ghostscript.Run(".setpdfwrite");
                    }
                    DoRunInitialize(ghostscript);
                    for (var i = 0; i < PageCount; i++)
                    {
                        DoRunPage(ghostscript, i + 1);
                        pageCompletedCallback?.Invoke();
                    }
                }
            }
예제 #4
0
 protected override void DoRunPage(Ghostscript ghostscript, int pageNumber)
 {
     // always run showpage
     base.DoRunPage(ghostscript, pageNumber);
     ghostscript.Run("showpage");
 }
예제 #5
0
 protected override void DoRunPage(Ghostscript ghostscript, int pageNumber)
 {
     // run the given page
     ghostscript.Run(_pages.Values[pageNumber - 1]);
 }
예제 #6
0
 protected override void DoRunPage(Ghostscript ghostscript, int pageNumber)
 {
     // run the page
     ghostscript.Run(string.Format(CultureInfo.InvariantCulture, "{0} pdfgetpage pdfshowpage", pageNumber));
 }