88using System . Xml . Serialization ;
99
1010// TODO Fix the generated casing in report.cs
11- // TODO Move stuff out of ctor
1211
1312namespace PdfAValidator
1413{
@@ -17,6 +16,23 @@ namespace PdfAValidator
1716 /// </summary>
1817 public class PdfAValidator : IDisposable
1918 {
19+ private const string maskedQuote = "\" " ;
20+ private string _pathVeraPdfDirectory ;
21+ /// <summary>
22+ /// Path to java jre used by windows
23+ /// </summary>
24+ /// <value></value>
25+ public string PathJava { private set ; get ; }
26+
27+ private readonly bool _customVerapdfAndJavaLocations ;
28+
29+ private bool isInitilized { get ; set ; }
30+
31+ /// <summary>
32+ /// Command that is used to invoke VeraPdf
33+ /// </summary>
34+ /// <value>Command with arguments</value>
35+ public string VeraPdfStartScript { private set ; get ; }
2036 /// <summary>
2137 /// Disposing verapdf bins
2238 /// </summary>
@@ -27,7 +43,6 @@ public void Dispose()
2743 Directory . Delete ( _pathVeraPdfDirectory , true ) ;
2844 }
2945 }
30-
3146 /// <summary>
3247 /// Use this constructor to use your own installation of VeraPdf and Java, e.g.: c:\somePath\verapdf.bat
3348 /// </summary>
@@ -38,28 +53,16 @@ public PdfAValidator(string pathToVeraPdfBin, string pathToJava)
3853 VeraPdfStartScript = pathToVeraPdfBin ;
3954 PathJava = pathToJava ;
4055 _customVerapdfAndJavaLocations = true ;
56+ isInitilized = true ;
4157 }
4258
4359 /// <summary>
4460 /// Use this constructor to use the embedded veraPdf binaries
4561 /// </summary>
4662 public PdfAValidator ( )
47- { intiPathToVeraPdfBinAndJava ( ) ; }
63+ { }
4864
49- private const string maskedQuote = "\" " ;
50- private string _pathVeraPdfDirectory ;
51- /// <summary>
52- /// Path to java jre used by windows
53- /// </summary>
54- /// <value></value>
55- public string PathJava { private set ; get ; }
5665
57- private readonly bool _customVerapdfAndJavaLocations ;
58- /// <summary>
59- ///
60- /// </summary>
61- /// <value></value>
62- public string VeraPdfStartScript { private set ; get ; }
6366 /// <summary>
6467 /// Validates a pdf to be compliant with the pdfa standard claimed by its meta data
6568 /// </summary>
@@ -76,6 +79,7 @@ public bool Validate(string pathToPdfFile)
7679 /// <returns></returns>
7780 public report ValidateWithDetailedReport ( string pathToPdfFile )
7881 {
82+ intiPathToVeraPdfBinAndJava ( ) ;
7983 var absolutePathToPdfFile = Path . GetFullPath ( pathToPdfFile ) ;
8084
8185 if ( ! File . Exists ( absolutePathToPdfFile ) )
@@ -131,10 +135,13 @@ private static T DeserializeXml<T>(string sourceXML) where T : class
131135 result = ( T ) serializer . Deserialize ( reader ) ;
132136 return result ;
133137 }
134-
135-
136138 private void intiPathToVeraPdfBinAndJava ( )
137139 {
140+ if ( isInitilized )
141+ {
142+ return ;
143+ }
144+
138145 _pathVeraPdfDirectory = Path . Combine ( Path . GetTempPath ( ) , "VeraPdf" + Guid . NewGuid ( ) ) ;
139146 Directory . CreateDirectory ( _pathVeraPdfDirectory ) ;
140147
@@ -155,6 +162,7 @@ private void intiPathToVeraPdfBinAndJava()
155162 {
156163 throw new NotImplementedException ( "Sorry, only supporting linux and windows." ) ;
157164 }
165+ isInitilized = true ;
158166 }
159167
160168 private static void SetLinuxFileExecuteable ( string filePath )
0 commit comments