@@ -14,38 +14,45 @@ namespace PostScriptValidator
1414 public class PostScriptValidator : IDisposable
1515 {
1616 private string pathGhostscriptDirectory ;
17+
1718 /// <summary>
18- /// Used Path to ghostscript bin
19+ /// Used Path to ghostscript bin
1920 /// </summary>
2021 /// <value>Path to ghostscript bin</value>
2122 public string GhostscriptBinPath { get ; private set ; }
23+
2224 /// <summary>
2325 /// Last exitcode from ghostscript
2426 /// </summary>
2527 /// <value>Is 0 if ghostscript could parse the validated postscript file</value>
2628 public int ExitCode { get ; private set ; }
29+
2730 /// <summary>
2831 /// Last stderr output from ghostscript
2932 /// </summary>
3033 /// <value>Can give you some hints if ghostscript failes to parse the validated postscript file</value>
3134
3235 public string ErrorMessage { get ; private set ; }
36+
3337 /// <summary>
3438 /// Last stdout output from ghostscript
3539 /// </summary>
3640 /// <value>Contains the stdout of the last validation session of ghostscript</value>
3741 public string StandardOutput { get ; private set ; }
42+
3843 private bool isInitilized ;
3944 private bool customGhostscriptlocation ;
4045 private bool disposed ;
4146 private readonly object lockObject = new object ( ) ;
4247 private const string c_maskedQuote = "\" " ;
48+
4349 /// <summary>
44- /// Use this constructor to use the embedded ghostscript binaries on windows, or guess the location on linux
50+ /// Use this constructor to use the embedded ghostscript binaries on windows, or guess the location on linux
4551 /// </summary>
4652 public PostScriptValidator ( )
4753 {
4854 }
55+
4956 /// <summary>
5057 /// Use this constructor to use custom ghostscritp bins, e.g. for ubuntu 18.04 /usr/bin/gs
5158 /// </summary>
@@ -55,14 +62,15 @@ public PostScriptValidator(string customPathToGhostscriptBin)
5562 customGhostscriptlocation = false ;
5663 isInitilized = true ;
5764 }
65+
5866 /// <summary>
5967 /// Validates a ps by trying to parse it using ghostscript
6068 /// </summary>
6169 /// <param name="pathToPsFile"></param>
6270 /// <returns>True for parseable postscript files</returns>
6371 public bool Validate ( string pathToPsFile )
6472 {
65- string absolutePathToPsFile = getAbsoluteFilePath ( pathToPsFile ) ;
73+ var absolutePathToPsFile = getAbsoluteFilePath ( pathToPsFile ) ;
6674
6775 //https://stackoverflow.com/questions/258132/validating-a-postscript-without-trying-to-print-it#2981290
6876 var ghostScriptArguments = new [ ] { "-sDEVICE=nullpage -dNOPAUSE -dBATCH " , c_maskedQuote , absolutePathToPsFile , c_maskedQuote } ;
@@ -84,7 +92,7 @@ public bool Validate(string pathToPsFile)
8492 /// <param name="pathToPdfFileWithEmbeddedFonts"></param>
8593 public void EmbedFonts ( string pathToPdfFile , string pathToPdfFileWithEmbeddedFonts )
8694 {
87- string absolutePathToPdfFile = getAbsoluteFilePath ( pathToPdfFile ) ;
95+ var absolutePathToPdfFile = getAbsoluteFilePath ( pathToPdfFile ) ;
8896
8997 // https://stackoverflow.com/questions/258132/validating-a-postscript-without-trying-to-print-it#2981290
9098
@@ -153,14 +161,13 @@ private void IntiPathToGhostscriptBin()
153161 isInitilized = true ;
154162 if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
155163 {
156-
157164 lock ( lockObject )
158165 {
159166 pathGhostscriptDirectory = Path . Combine ( Path . GetTempPath ( ) , "Ghostscript" + Guid . NewGuid ( ) ) ;
160167 Directory . CreateDirectory ( pathGhostscriptDirectory ) ;
161168
162- ExtractBinaryFromManifest ( "PostScriptValidator.gs9.27 .zip" ) ;
163- GhostscriptBinPath = Path . Combine ( pathGhostscriptDirectory , @"gs9.27 \bin" , "gswin32c.exe" ) ;
169+ ExtractBinaryFromManifest ( "PostScriptValidator.gs9.50 .zip" ) ;
170+ GhostscriptBinPath = Path . Combine ( pathGhostscriptDirectory , @"gs9.50 \bin" , "gswin32c.exe" ) ;
164171
165172 isInitilized = true ;
166173 }
@@ -175,6 +182,7 @@ private void IntiPathToGhostscriptBin()
175182 throw new NotImplementedException ( "Sorry, only supporting linux and windows." ) ;
176183 }
177184 }
185+
178186 private static string GetStreamOutput ( StreamReader stream )
179187 {
180188 //Read output i<n separate task to avoid deadlocks
@@ -185,7 +193,7 @@ private static string GetStreamOutput(StreamReader stream)
185193
186194 private void ExtractBinaryFromManifest ( string resourceName )
187195 {
188- var pathZipGhostscript = Path . Combine ( pathGhostscriptDirectory , "gs9.27 .zip" ) ;
196+ var pathZipGhostscript = Path . Combine ( pathGhostscriptDirectory , "gs9.50 .zip" ) ;
189197 var assembly = Assembly . GetExecutingAssembly ( ) ;
190198
191199 using ( var stream = assembly . GetManifestResourceStream ( resourceName ) )
@@ -196,6 +204,7 @@ private void ExtractBinaryFromManifest(string resourceName)
196204 }
197205 ZipFile . ExtractToDirectory ( pathZipGhostscript , pathGhostscriptDirectory ) ;
198206 }
207+
199208 /// <summary>
200209 /// Disposing ghostscript bins
201210 /// </summary>
0 commit comments