示例#1
0
 /* ----------------------------------------------------------------- */
 ///
 /// 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);
 }
示例#2
0
        /* ----------------------------------------------------------------- */
        ///
        /// 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; }
        }
示例#3
0
 /* ----------------------------------------------------------------- */
 ///
 /// 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");
             }
         }
     }
 }
示例#4
0
 /* ----------------------------------------------------------------- */
 ///
 /// 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)
 {
 }
示例#5
0
 /* ----------------------------------------------------------------- */
 ///
 /// 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)
 {
 }
示例#6
0
 /* ----------------------------------------------------------------- */
 ///
 /// 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)
 {
 }
示例#7
0
 /* ----------------------------------------------------------------- */
 ///
 /// 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)
 {
 }