protected override void DoRunInitialize(Ghostscript ghostscript) { // run the prolog if there is any if (_prologAndSetup != null) { ghostscript.Run(_prologAndSetup); } }
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)); }
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(); } } }
protected override void DoRunPage(Ghostscript ghostscript, int pageNumber) { // always run showpage base.DoRunPage(ghostscript, pageNumber); ghostscript.Run("showpage"); }
protected override void DoRunPage(Ghostscript ghostscript, int pageNumber) { // run the given page ghostscript.Run(_pages.Values[pageNumber - 1]); }
protected override void DoRunPage(Ghostscript ghostscript, int pageNumber) { // run the page ghostscript.Run(string.Format(CultureInfo.InvariantCulture, "{0} pdfgetpage pdfshowpage", pageNumber)); }