Ejemplo n.º 1
0
        /// <summary>
        /// Gets the object of type <see cref="PdfPageObject"/> by given object index.
        /// </summary>
        /// <param name="index">The index to get object.</param>
        /// <returns></returns>
        /// <exception cref="IndexOutOfRangeException"/>
        /// <exception cref="NotImplementedException">When try to set an <see cref="PdfPageObject"/>.</exception>
        /// <exception cref="PDFiumException"/>
        public PdfPageObject this[int index]
        {
            get
            {
                if (index < 0 || index >= Count)
                {
                    throw new IndexOutOfRangeException();
                }

                FPDF_PAGEOBJECT pageObj = _pdfPage != null
                    ? PDFium.FPDFPage_GetObject(_pdfPage.Handle, index)
                    : PDFium.FPDFFormObj_GetObject(_formObject, index);

                if (pageObj.IsNull)
                {
                    throw new PDFiumException();
                }

                return(_pageObjectManager.Create(_pdfPage.Handle, pageObj));
            }
            set
            {
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 2
0
        public PdfPageObject Create(FPDF_PAGE page, FPDF_PAGEOBJECT pageObject)
        {
            if (pageObject.IsNull)
            {
                return(null);
            }

            PageObjTypes pageObjectType = GetPageObjectType(pageObject);

            if (_list.ContainsKey(pageObject))
            {
                PDFPageObjectTypeKeyValuePair mgrIntObjVal = _list[pageObject];
                if (mgrIntObjVal.objType == pageObjectType)
                {
                    return(mgrIntObjVal.obj);
                }
                _list.Remove(pageObject);
            }

            PDFPageObjectTypeKeyValuePair mgrIntObjVal2 = new PDFPageObjectTypeKeyValuePair
            {
                obj     = PdfPageObject.Create(page, pageObject),
                objType = pageObjectType
            };

            this._list.Add(pageObject, mgrIntObjVal2);

            return(mgrIntObjVal2.obj);
        }
Ejemplo n.º 3
0
 internal void Remove(FPDF_PAGEOBJECT handle)
 {
     if (this._list.ContainsKey(handle))
     {
         this._list.Remove(handle);
     }
 }
Ejemplo n.º 4
0
 internal PdfPageObjectsCollection(FPDF_PAGEOBJECT formObject)
 {
     if (formObject.IsNull)
     {
         throw new ArgumentNullException(nameof(formObject));
     }
     _formObject = formObject;
 }
Ejemplo n.º 5
0
        //public static PdfTypeNumber Create(int initialVal)
        //{
        //	IntPtr expr_06 = PDFium.FPDFNUMBER_CreateInt(initialVal);
        //	if (expr_06 == IntPtr.Zero)
        //	{
        //		throw new PDFiumException();
        //	}
        //	return new PdfTypeNumber(expr_06);
        //}

        //public static PdfTypeNumber Create(float initialVal)
        //{
        //	IntPtr expr_06 = PDFium.FPDFNUMBER_CreateFloat(initialVal);
        //	if (expr_06 == IntPtr.Zero)
        //	{
        //		throw new PDFiumException();
        //	}
        //	return new PdfTypeNumber(expr_06);
        //}

        public new static PdfTypeNumber Create(FPDF_PAGEOBJECT handle)
        {
            if (handle.IsNull)
            {
                throw new ArgumentException();
            }
            return(new PdfTypeNumber(handle));
        }
Ejemplo n.º 6
0
        public static PdfTypeBoolean Create(bool bInitialVal)
        {
            FPDF_PAGEOBJECT expr_06 = PDFium.FPDFBOOLEAN_Create(bInitialVal);

            if (expr_06.IsNull)
            {
                throw new PDFiumException();
            }
            return(new PdfTypeBoolean(expr_06));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Load an image from a JPEG image file and then set it into <paramref name="image_object"/>.
 /// </summary>
 /// <param name="loadedPages">All loaded pages, may be <c>null</c>.</param>
 /// <param name="image_object">Handle to an image object.</param>
 /// <param name="stream">Stream which provides access to an JPEG image.</param>
 /// <param name="count">The number of bytes to read from <paramref name="stream"/> or 0 to read to the end.</param>
 /// <param name="inline">
 /// If <c>true</c>, this function loads the JPEG image inline, so the image
 /// content is copied to the file. This allows <paramref name="stream"/>
 /// to be closed after this function returns.
 /// </param>
 /// <returns><c>true</c> on success.</returns>
 /// <remarks>
 /// The image object might already have an associated image, which is shared and
 /// cached by the loaded pages. In that case, we need to clear the cached image
 /// for all the loaded pages. Pass <paramref name="loadedPages"/> to this API
 /// to clear the image cache. If the image is not previously shared, <c>null</c> is a
 /// valid <paramref name="loadedPages"/> value.
 /// </remarks>
 public static bool FPDFImageObj_LoadJpegFile(FPDF_PAGE[] loadedPages, FPDF_PAGEOBJECT image_object, Stream stream, int count = 0, bool inline = true)
 {
     if (inline)
     {
         return(FPDFImageObj_LoadJpegFileInline(ref loadedPages[0], loadedPages.Length, image_object, FPDF_FILEREAD.FromStream(stream, count)));
     }
     else
     {
         return(FPDFImageObj_LoadJpegFile(ref loadedPages[0], loadedPages.Length, image_object, FPDF_FILEREAD.FromStream(stream, count)));
     }
 }
Ejemplo n.º 8
0
        public static PdfPageObject Create(FPDF_PAGE page, FPDF_PAGEOBJECT pageObj)
        {
            switch (PDFium.FPDFPageObj_GetType(pageObj))
            {
            case PageObjTypes.Text:
                return(new PdfTextObject(page, pageObj));

            case PageObjTypes.Path:
                return(new PdfPathObject(page, pageObj));

            case PageObjTypes.Image:
                return(new PdfImageObject(page, pageObj));

            case PageObjTypes.Shading:
                return(new PdfShadingObject(page, pageObj));

            case PageObjTypes.Form:
                return(new PdfFormObject(page, pageObj));

            default:
                return(new PdfUnknownObject(page, pageObj));
            }
        }
Ejemplo n.º 9
0
 internal PdfTypeBoolean(FPDF_PAGEOBJECT handle) : base(handle)
 {
 }
Ejemplo n.º 10
0
 public PdfUnknownObject(FPDF_PAGE page, FPDF_PAGEOBJECT handle) : base(page, handle)
 {
 }
Ejemplo n.º 11
0
 protected PdfPageObject(FPDF_PAGE pageHandle, FPDF_PAGEOBJECT pageObjectHandle)
 {
     PageHandle       = pageHandle;
     PageObjectHandle = pageObjectHandle;
 }
Ejemplo n.º 12
0
        public void FPDF_PAGEOBJECT_Constructor_Call2_Success()
        {
            var h = new FPDF_PAGEOBJECT(new IntPtr(1));

            Assert.IsTrue(h.IsValid);
        }
Ejemplo n.º 13
0
 public PdfFormObject(FPDF_PAGE pageHandle, FPDF_PAGEOBJECT formObject) : base(pageHandle, formObject)
 {
     PageObjects = new PdfPageObjectsCollection(formObject);
 }
Ejemplo n.º 14
0
 public PdfImageObject(FPDF_PAGE pageHandle, FPDF_PAGEOBJECT imageObj) : base(pageHandle, imageObj)
 {
     _pdfBitmap = new Lazy <FPDF_BITMAP>(() => PDFium.FPDFImageObj_GetBitmap(imageObj));
 }
Ejemplo n.º 15
0
        public void FPDF_PAGEOBJECT_Constructor_Call1_Success()
        {
            var h = new FPDF_PAGEOBJECT();

            Assert.IsFalse(h.IsValid);
        }
Ejemplo n.º 16
0
 internal PageObjTypes GetPageObjectType(FPDF_PAGEOBJECT pageObject)
 {
     return(PDFium.FPDFPageObj_GetType(pageObject));
 }
Ejemplo n.º 17
0
 public static string FPDFTextObj_GetTextUnicode(FPDF_PAGEOBJECT page_object, FPDF_TEXTPAGE text_page)
 {
     return(GetUtf16String((ref byte buffer, int length) => (int)FPDFTextObj_GetText(page_object, text_page, ref buffer, length), sizeof(ushort), false));
 }
Ejemplo n.º 18
0
 internal PdfTypeNumber(FPDF_PAGEOBJECT handle) : base(handle)
 {
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Get the page label for <paramref name="page_index"/> from <paramref name="document"/>.
        /// </summary>
        /// <param name="document">Handle to the document.</param>
        /// <param name="page_index">The zero-based index of the page.</param>
        /// <returns>The page label.</returns>
        /// <seealso cref="PdfPage.Label"/>
        //public static string FPDF_GetPageLabel(FPDF_DOCUMENT document, int page_index)
        //{
        //	return GetUtf16String((ref byte buffer, int length) => (int)FPDF_GetPageLabel(document, page_index, ref buffer, (uint)length), sizeof(byte), true);
        //}

        #endregion

        #region https: //pdfium.googlesource.com/pdfium/+/master/public/fpdf_edit.h

        /// <summary>
        ///     Insert <paramref name="page_obj" /> into <paramref name="page" />.
        /// </summary>
        /// <param name="page">Handle to a page.</param>
        /// <param name="page_obj">Handle to a page object. The <paramref name="page_obj" /> will be automatically freed.</param>
        public static void FPDFPage_InsertObject(FPDF_PAGE page, ref FPDF_PAGEOBJECT page_obj)
        {
            FPDFPage_InsertObject(page, page_obj);
            page_obj = FPDF_PAGEOBJECT.Null;
        }
Ejemplo n.º 20
0
 public static string FPDFTextObj_GetTextAnsi(FPDF_PAGEOBJECT page_object, FPDF_TEXTPAGE text_page)
 {
     return(GetAsciiString((ref byte buffer, int length) => (int)FPDFTextObj_GetText(page_object, text_page, ref buffer, length)));
 }
Ejemplo n.º 21
0
 public PdfShadingObject(FPDF_PAGE pageHandle, FPDF_PAGEOBJECT pageObjectHandle) : base(pageHandle, pageObjectHandle)
 {
 }
Ejemplo n.º 22
0
 internal PdfTextObject(FPDF_PAGE pageHandle, FPDF_PAGEOBJECT pageObjectHandle) : base(pageHandle, pageObjectHandle)
 {
     pdfPageLazy = new Lazy <FPDF_TEXTPAGE>(() => PDFium.FPDFText_LoadPage(PageHandle));
 }
Ejemplo n.º 23
0
 /// <summary>
 ///     Set <paramref name="bitmap" /> to <paramref name="image_object" />.
 /// </summary>
 /// <param name="loadedPages">All loaded pages, may be <c>null</c>.</param>
 /// <param name="image_object">Handle to an image object.</param>
 /// <param name="bitmap">Handle of the bitmap.</param>
 /// <returns><c>true</c> on success.</returns>
 public static bool FPDFImageObj_SetBitmap(FPDF_PAGE[] loadedPages, FPDF_PAGEOBJECT image_object, FPDF_BITMAP bitmap)
 => FPDFImageObj_SetBitmap(ref loadedPages[0], loadedPages.Length, image_object, bitmap);
Ejemplo n.º 24
0
 public PdfPathObject(FPDF_PAGE pageHandle, FPDF_PAGEOBJECT pathObject) : base(pageHandle, pathObject)
 {
 }