// // factory methods // #region public static PDFFile Load(string path, PDFTraceLog log) /// <summary> /// Loads a new PDFFile with the data from the specified path - Must be disposed after use. /// </summary> /// <param name="path"></param> /// <param name="log"></param> /// <returns></returns> public static PDFFile Load(string path, PDFTraceLog log) { if (log.ShouldLog(TraceLevel.Message)) { log.Begin(TraceLevel.Message, PDFFileLogCategory, "Creating a new PDFFile to read the existing data from a file at path '" + path + "'"); } PDFFile file = new PDFFile(); file._log = log; file._innerStream = GetFileStreamForPath(path); file._reader = PDFReader.Create(file._innerStream, log); file._canAppend = true; file._origpath = path; file.Init(); if (log.ShouldLog(TraceLevel.Message)) { log.End(TraceLevel.Message, PDFFileLogCategory, "A new PDFFile was read from the existing data from the file"); } return(file); }
/// <summary> /// Loads a PDFFile from the specified stream recoding process in the log. The stream position /// </summary> /// <param name="stream"></param> /// <param name="log"></param> /// <returns></returns> public static PDFFile Load(System.IO.Stream stream, PDFTraceLog log) { if (log.ShouldLog(TraceLevel.Message)) { log.Begin(TraceLevel.Message, PDFFileLogCategory, "Creating a new PDFFile to read the existing data from a stream"); } PDFFile file = new PDFFile(); file._log = log; file._innerStream = stream; file._reader = PDFReader.Create(stream, log); file._canAppend = stream.CanWrite; file._origpath = string.Empty; file.Init(); if (log.ShouldLog(TraceLevel.Message)) { log.End(TraceLevel.Message, PDFFileLogCategory, "A new PDFFile was read from the existing data from a stream"); } return(file); }