/* ----------------------------------------------------------------- */ /// /// DocumentReader /// /// <summary> /// Initializes a new instance of the DocumentReader class with /// the specified arguments. /// </summary> /// /// <param name="src">Path of the PDF file.</param> /// <param name="password">Password query or string.</param> /// <param name="options">Other options.</param> /// /* ----------------------------------------------------------------- */ private DocumentReader(string src, QueryMessage <IQuery <string>, string> password, OpenOption options ) { Core = PdfiumReader.Create(src, password, options); }
/* ----------------------------------------------------------------- */ /// /// Create /// /// <summary> /// Creates a new instance of the PdfiumReader class with the /// specified arguments. /// </summary> /// /// <param name="src">Path of the PDF file.</param> /// <param name="password">Password string or query.</param> /// <param name="options">Other options.</param> /// /// <returns>PdfiumReader object.</returns> /// /* ----------------------------------------------------------------- */ public static PdfiumReader Create(string src, QueryMessage <IQuery <string>, string> password, OpenOption options ) { var dest = new PdfiumReader(src, options.IO); try { Load(src, dest, password, options); return(dest); } catch { dest.Dispose(); throw; } }
/* ----------------------------------------------------------------- */ /// /// Load /// /// <summary> /// Loads the PDF document with the specified arguments. /// </summary> /// /* ----------------------------------------------------------------- */ private static void Load(string src, PdfiumReader dest, QueryMessage <IQuery <string>, string> password, OpenOption options ) { while (true) { try { dest.Load(password.Value); var denied = options.FullAccess && dest.File is PdfFile f && !f.FullAccess; if (denied) { throw new PdfiumException(PdfiumStatus.PasswordError); } else { return; } } catch (PdfiumException err) { if (err.Status != PdfiumStatus.PasswordError) { throw; } var msg = password.Source.Request(src); if (!msg.Cancel) { password.Value = msg.Value; } else { throw new OperationCanceledException("Password"); } } } }
/* ----------------------------------------------------------------- */ /// /// DocumentRenderer /// /// <summary> /// Initializes a new instance of the DocumentRenderer class /// with the specified arguments. /// </summary> /// /// <param name="src">Path of the PDF file.</param> /// <param name="password">Password string.</param> /// <param name="options">Other options.</param> /// /* ----------------------------------------------------------------- */ public DocumentRenderer(string src, string password, OpenOption options) : base(src, password, options) { }
/* ----------------------------------------------------------------- */ /// /// DocumentRenderer /// /// <summary> /// Initializes a new instance of the DocumentRenderer class /// with the specified arguments. /// </summary> /// /// <param name="src">Path of the PDF file.</param> /// <param name="query">Password query.</param> /// <param name="options">Other options.</param> /// /* ----------------------------------------------------------------- */ public DocumentRenderer(string src, IQuery <string> query, OpenOption options) : base(src, query, options) { }
/* ----------------------------------------------------------------- */ /// /// DocumentReader /// /// <summary> /// Initializes a new instance of the DocumentReader class /// with the specified arguments. /// </summary> /// /// <param name="src">Path of the PDF file.</param> /// <param name="password">Password string.</param> /// <param name="options">Other options.</param> /// /* ----------------------------------------------------------------- */ public DocumentReader(string src, string password, OpenOption options) : this(src, MakeQuery(null, password), options) { }
/* ----------------------------------------------------------------- */ /// /// DocumentReader /// /// <summary> /// Initializes a new instance of the DocumentReader class /// with the specified arguments. /// </summary> /// /// <param name="src">Path of the PDF file.</param> /// <param name="query">Password query.</param> /// <param name="options">Other options.</param> /// /* ----------------------------------------------------------------- */ public DocumentReader(string src, IQuery <string> query, OpenOption options) : this(src, MakeQuery(query, string.Empty), options) { }