Exemplo n.º 1
0
        /* ----------------------------------------------------------------- */
        ///
        /// Load
        ///
        /// <summary>
        /// Loads the PDF document.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private void Load(string password)
        {
            _core = Invoke(() => NativeMethods.FPDF_LoadCustomDocument(
                               new FileAccess
            {
                Length    = (uint)_stream.Length,
                GetBlock  = Marshal.GetFunctionPointerForDelegate(_handler),
                Parameter = IntPtr.Zero,
            },
                               password
                               ));

            if (_core == IntPtr.Zero)
            {
                throw GetLastError();
            }

            Metadata   = MetadataFactory.Create(this);
            Encryption = EncryptionFactory.Create(this, password);
            File       = FileFactory.Create(this, password, !Encryption.OpenWithPassword);
            Pages      = new PageCollection(this, File);
        }
Exemplo n.º 2
0
        /* ----------------------------------------------------------------- */
        ///
        /// Load
        ///
        /// <summary>
        /// Loads the PDF document.
        /// </summary>
        ///
        /// <param name="password">Password.</param>
        ///
        /* ----------------------------------------------------------------- */
        private void Load(string password)
        {
            var core = PdfiumApi.FPDF_LoadCustomDocument(
                new FileAccess
            {
                Length    = (uint)_stream.Length,
                GetBlock  = Marshal.GetFunctionPointerForDelegate(_delegate),
                Parameter = IntPtr.Zero,
            },
                password
                );

            if (core == IntPtr.Zero)
            {
                throw GetLastError();
            }

            _core      = core;
            Encryption = EncryptionFactory.Create(this, password);
            File       = Create(password, !Encryption.OpenWithPassword);
            Pages      = new ReadOnlyPageList(this, File);
            Metadata   = MetadataFactory.Create(this);
        }