Beispiel #1
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);
        }
 /// <summary>
 /// Prepare information about all characters in a page.
 /// </summary>
 /// <param name="page">Handle to the page. Returned by FPDF_LoadPage function (in FPDFVIEW module).</param>
 /// <returns>A handle to the text page information structure. NULL if something goes wrong.</returns>
 /// <remarks>
 /// Application must call FPDFText_ClosePage to release the text page information.
 /// FPDF_EXPORT FPDF_TEXTPAGE FPDF_CALLCONV FPDFText_LoadPage(FPDF_PAGE page);.
 /// </remarks>
 public FPDF_TEXTPAGE FPDFText_LoadPage(FPDF_PAGE page)
 {
     lock (_syncObject)
     {
         return(FPDFText_LoadPageStatic(page));
     }
 }
 /// <summary>
 /// Find the Z-order of link at point (|x|,|y|) on |page|.
 /// </summary>
 /// <param name="page">Handle to the document page.</param>
 /// <param name="x">The x coordinate, in the page coordinate system.</param>
 /// <param name="y">The y coordinate, in the page coordinate system.</param>
 /// <returns>Returns the Z-order of the link, or -1 if no link found at the given point.
 /// Larger Z-order numbers are closer to the front.</returns>
 /// <remarks>
 /// You can convert coordinates from screen coordinates to page coordinates using FPDF_DeviceToPage().
 /// FPDF_EXPORT int FPDF_CALLCONV FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y);.
 /// </remarks>
 public int FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y)
 {
     lock (_syncObject)
     {
         return(FPDFLink_GetLinkZOrderAtPointStatic(page, x, y));
     }
 }
 /// <summary>
 /// Experimental API
 /// Gets an additional-action from |page|.
 /// </summary>
 /// <param name="page">Handle to the page, as returned by FPDF_LoadPage().</param>
 /// <param name="aa_type">The type of the page object's addtional-action, defined in public/fpdf_formfill.h.</param>
 /// <returns>Returns the handle to the action data, or NULL if there is no additional-action of type |aa_type|.</returns>
 /// <remarks>
 /// FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDF_GetPageAAction(FPDF_PAGE page, int aa_type);.
 /// </remarks>
 public FPDF_ACTION FPDF_GetPageAAction(FPDF_PAGE page, int aa_type)
 {
     lock (_syncObject)
     {
         return(FPDF_GetPageAActionStatic(page, aa_type));
     }
 }
 /// <summary>
 /// Gets FPDF_ANNOTATION object for |link_annot|. Experimental API.
 /// </summary>
 /// <param name="page">Handle to the page in which FPDF_LINK object is present.</param>
 /// <param name="link_annot">Handle to link annotation.</param>
 /// <returns>Returns FPDF_ANNOTATION from the FPDF_LINK and NULL on failure, if the input link annot or page is NULL.</returns>
 /// <remarks>
 /// FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFLink_GetAnnot(FPDF_PAGE page, FPDF_LINK link_annot);.
 /// </remarks>
 public FPDF_ANNOTATION FPDFLink_GetAnnot(FPDF_PAGE page, FPDF_LINK link_annot)
 {
     lock (_syncObject)
     {
         return(FPDFLink_GetAnnotStatic(page, link_annot));
     }
 }
 /// <summary>
 /// Enumerates all the link annotations in |page|.
 /// </summary>
 /// <param name="page">Handle to the page.</param>
 /// <param name="start_pos">The start position, should initially be 0 and is updated with the next start position on return.</param>
 /// <param name="link_annot">The link handle for |startPos|.</param>
 /// <returns>Returns TRUE on success.</returns>
 /// <remarks>
 /// FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_Enumerate(FPDF_PAGE page, int* start_pos, FPDF_LINK* link_annot);.
 /// </remarks>
 public bool FPDFLink_Enumerate(FPDF_PAGE page, ref int start_pos, ref FPDF_LINK link_annot)
 {
     lock (_syncObject)
     {
         return(FPDFLink_EnumerateStatic(page, ref start_pos, ref link_annot));
     }
 }
Beispiel #7
0
        /// <summary>
        ///     Enumerates all the link annotations in <paramref name="page" />.
        /// </summary>
        /// <param name="page">Handle to the page.</param>
        /// <returns>All the link annotations in <paramref name="page" />.</returns>
        public static IEnumerable <FPDF_LINK> FPDFLink_Enumerate(FPDF_PAGE page)
        {
            var pos = 0;

            while (FPDFLink_Enumerate(page, ref pos, out var link))
            {
                yield return(link);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Render the page to the bitmap.
        /// </summary>
        /// <param name="page">Page to render.</param>
        /// <param name="zoomFactor">Zoom factor to use for transformation.</param>
        /// <param name="startX">Left pixel position of the page area to render.</param>
        /// <param name="startY">Top pixel position of the page area to render.</param>
        /// <param name="sizeX">Width of the page area to render.</param>
        /// <param name="sizeY">Height of the page area to render.</param>
        /// <param name="flags">Rendering flags to use for rendering.</param>
        public void RenderWithTransformation(FPDF_PAGE page, double zoomFactor, int startX, int startY, int sizeX, int sizeY, FPDF_RENDERING_FLAGS flags)
        {
            // Translation is performed with [1 0 0 1 tx ty].
            // Scaling is performed with [sx 0 0 sy 0 0].
            FS_MATRIX matrix = new FS_MATRIX {
                A = (float)zoomFactor, B = 0, C = 0, D = (float)zoomFactor, E = startX > 0f ? 0f : startX, F = startY > 0f ? 0f : startY
            };
            FS_RECTF rect = new FS_RECTF {
                Left = startX, Right = startX + sizeX, Top = startY, Bottom = startY + sizeY
            };

            _mainComponent.PDFiumBridge.FPDF_RenderPageBitmapWithMatrix(_bitmapHandle, page, ref matrix, ref rect, flags);
        }
Beispiel #9
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));
            }
        }
Beispiel #10
0
 protected PdfPageObject(FPDF_PAGE pageHandle, FPDF_PAGEOBJECT pageObjectHandle)
 {
     PageHandle       = pageHandle;
     PageObjectHandle = pageObjectHandle;
 }
 public PdfUnknownObject(FPDF_PAGE page, FPDF_PAGEOBJECT handle) : base(page, handle)
 {
 }
Beispiel #12
0
 public PdfFormObject(FPDF_PAGE pageHandle, FPDF_PAGEOBJECT formObject) : base(pageHandle, formObject)
 {
     PageObjects = new PdfPageObjectsCollection(formObject);
 }
Beispiel #13
0
        public void FPDF_PAGE_Constructor_Call2_Success()
        {
            var h = new FPDF_PAGE(new IntPtr(1));

            Assert.IsTrue(h.IsValid);
        }
Beispiel #14
0
 public PdfShadingObject(FPDF_PAGE pageHandle, FPDF_PAGEOBJECT pageObjectHandle) : base(pageHandle, pageObjectHandle)
 {
 }
Beispiel #15
0
 internal PdfTextObject(FPDF_PAGE pageHandle, FPDF_PAGEOBJECT pageObjectHandle) : base(pageHandle, pageObjectHandle)
 {
     pdfPageLazy = new Lazy <FPDF_TEXTPAGE>(() => PDFium.FPDFText_LoadPage(PageHandle));
 }
Beispiel #16
0
 public PdfImageObject(FPDF_PAGE pageHandle, FPDF_PAGEOBJECT imageObj) : base(pageHandle, imageObj)
 {
     _pdfBitmap = new Lazy <FPDF_BITMAP>(() => PDFium.FPDFImageObj_GetBitmap(imageObj));
 }
Beispiel #17
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;
        }
Beispiel #18
0
        public void FPDF_PAGE_Constructor_Call1_Success()
        {
            var h = new FPDF_PAGE();

            Assert.IsFalse(h.IsValid);
        }
Beispiel #19
0
 /// <summary>
 /// Render the page to the bitmap.
 /// </summary>
 /// <param name="page">Page to render.</param>
 /// <param name="startX">Left pixel position of the page area to render.</param>
 /// <param name="startY">Top pixel position of the page area to render.</param>
 /// <param name="sizeX">Width of the page area to render.</param>
 /// <param name="sizeY">Height of the page area to render.</param>
 /// <param name="flags">Rendering flags to use for rendering.</param>
 public void RenderWithoutTransformation(FPDF_PAGE page, int startX, int startY, int sizeX, int sizeY, FPDF_RENDERING_FLAGS flags)
 {
     _mainComponent.PDFiumBridge.FPDF_RenderPageBitmap(_bitmapHandle, page, startX, startY, sizeX, sizeY, 0, flags);
 }
Beispiel #20
0
 public PdfPathObject(FPDF_PAGE pageHandle, FPDF_PAGEOBJECT pathObject) : base(pageHandle, pathObject)
 {
 }