示例#1
0
        protected virtual void Dispose(bool disposing)
        {
            if (!m_Disposed)
            {
                lock (PDFLibrary.nativeLock)
                {
                    if (m_NativePointer != IntPtr.Zero)
                    {
                        s_InstanceMap[m_NativePointer] = s_InstanceMap[m_NativePointer] - 1;

                        if (s_InstanceMap[m_NativePointer] == 0)
                        {
                            if (m_Page.NativePointer != IntPtr.Zero && m_Page.Document.NativePointer != IntPtr.Zero)
                            {
                                FPDFText_ClosePage(m_NativePointer);
                            }
                            s_InstanceMap.Remove(m_NativePointer);
                            m_NativePointer = IntPtr.Zero;
                        }
                    }
                }

                PDFLibrary.RemoveRef("PDFTextPage");

                m_Disposed = true;
            }
        }
示例#2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!m_Disposed)
            {
                if (m_NativePointer != IntPtr.Zero)
                {
#if !UNITY_WEBGL || UNITY_EDITOR
                    lock (PDFLibrary.nativeLock)
                    {
                        s_InstanceMap[m_NativePointer] = s_InstanceMap[m_NativePointer] - 1;

                        if (s_InstanceMap[m_NativePointer] == 0)
                        {
                            if (m_Document.NativePointer != IntPtr.Zero)
                            {
                                FPDF_ClosePage(m_NativePointer);
                            }
                            s_InstanceMap.Remove(m_NativePointer);
                            m_NativePointer = IntPtr.Zero;
                        }
                    }
#else
                    PDFJS_ClosePage(m_NativePointer.ToInt32());
                    m_NativePointer = IntPtr.Zero;
#endif
                }

                PDFLibrary.RemoveRef("PDFPage");

                m_Disposed = true;
            }
        }
示例#3
0
        internal static void RemoveRef(string token)
        {
            lock (nativeLock)
            {
                --m_RefCount;

#if PDFRENDERER_DEBUG
                s_InstanceMap[token] = s_InstanceMap[token] - 1;
#endif
                if (m_RefCount == 0)
                {
                    if (m_Disposed)
                    {
#if PDFRENDERER_DEBUG
                        PrintInstanceMap();
#endif
#if !UNITY_WEBGL || UNITY_EDITOR
                        if (!m_AlreadyDestroyed)
                        {
                            m_AlreadyDestroyed = true;
                            FPDF_DestroyLibrary();
                        }
#endif

                        m_Instance = null;
                    }
                    else
                    {
                        m_Instance.Dispose();
                    }
                }
            }
        }
示例#4
0
        protected virtual void Dispose(bool disposing)
        {
            lock (nativeLock)
            {
                if (!m_Disposed)
                {
                    if (m_RefCount == 0)
                    {
#if PDFRENDERER_DEBUG
                        PrintInstanceMap();
#endif

#if !UNITY_WEBGL || UNITY_EDITOR
                        if (!m_AlreadyDestroyed)
                        {
                            m_AlreadyDestroyed = true;
#if UNITY_EDITOR
                            FPDF_DestroyLibrary();
#endif
                        }
#endif

                        m_Disposed = true;
                        m_Instance = null;
                    }

                    m_Disposed = true;
                }
            }
        }
示例#5
0
        public PDFPage(PDFDocument document, int pageIndex)
        {
            if (document == null)
            {
                throw new NullReferenceException();
            }
            if (pageIndex < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            PDFLibrary.AddRef("PDFPage");

            m_Document  = document;
            m_PageIndex = pageIndex;

            m_NativePointer = FPDF_LoadPage(document.NativePointer, m_PageIndex);

            if (m_NativePointer != IntPtr.Zero)
            {
                if (s_InstanceMap.ContainsKey(m_NativePointer))
                {
                    s_InstanceMap[m_NativePointer] = s_InstanceMap[m_NativePointer] + 1;
                }
                else
                {
                    s_InstanceMap[m_NativePointer] = 1;
                }
            }
        }
示例#6
0
        public PDFDocument(IntPtr nativePointer)
        {
            PDFLibrary.AddRef("PDFDocument");

            m_NativePointer = nativePointer;
            m_ValidDocument = true;
        }
示例#7
0
        public PDFBookmark(PDFDocument document, PDFBookmark parentBookmark, IntPtr nativePointer, IPDFDevice device)
        {
            if (document == null)
            {
                throw new NullReferenceException();
            }

            m_ParentBookmark = parentBookmark;
            m_NativePointer  = nativePointer;
            m_Document       = document;
            m_Device         = device;

            if (m_NativePointer == IntPtr.Zero)
            {
                m_Title = "ROOT";
            }

            PDFLibrary.AddRef("PDFBookmark");

            PDFBookmark firstChild = GetFirstChild();

            if (firstChild != null)
            {
                PDFBookmark previousSibling = firstChild;

                while (previousSibling != null)
                {
                    m_Bookmarks.Add(previousSibling);
                    previousSibling = previousSibling.GetNextSibling();
                }
            }
        }
示例#8
0
        public PDFPage(PDFDocument document, IntPtr pageHandle, int pageIndex)
        {
            PDFLibrary.AddRef("PDFPage");

            m_Document  = document;
            m_PageIndex = pageIndex;

            m_NativePointer = pageHandle;
        }
示例#9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="password">Can be null or empty</param>
        public PDFDocument(string filePath, string password)
        {
            PDFLibrary.AddRef("PDFDocument");

#if !UNITY_WEBPLAYER
            CommonInit(File.ReadAllBytes(filePath), password);
#else
            m_ValidDocument = false;
#endif
        }
示例#10
0
        protected virtual void Dispose(bool disposing)
        {
            if (!m_Disposed)
            {
                m_NativePointer = IntPtr.Zero;

                PDFLibrary.RemoveRef("PDFAction");

                m_Disposed = true;
            }
        }
示例#11
0
        public PDFLink(PDFPage page, IntPtr nativePointer)
        {
            if (page == null)
            {
                throw new NullReferenceException();
            }
            if (nativePointer == IntPtr.Zero)
            {
                throw new NullReferenceException();
            }

            PDFLibrary.AddRef("PDFLink");

            m_Page = page;

            m_NativePointer = nativePointer;
        }
示例#12
0
        protected virtual void Dispose(bool disposing)
        {
            if (!m_Disposed)
            {
                if (disposing)
                {
#if !UNITY_WEBGL || UNITY_EDITOR
                    m_Bitmap.Dispose();
                    m_Bitmap = null;
#endif
                }

                PDFLibrary.RemoveRef("PDFRenderer");

                m_Disposed = true;
            }
        }
示例#13
0
        protected virtual void Dispose(bool disposing)
        {
            if (!m_Disposed)
            {
                lock (PDFLibrary.nativeLock)
                {
                    if (m_NativePointer != IntPtr.Zero)
                    {
                        FPDFText_FindClose(m_NativePointer);
                        m_NativePointer = IntPtr.Zero;
                    }
                }

                PDFLibrary.RemoveRef("PDFSearchHandle");

                m_Disposed = true;
            }
        }
示例#14
0
        public PDFAction(PDFBookmark bookmark, IntPtr nativePointer)
        {
            if (bookmark == null)
            {
                throw new NullReferenceException();
            }
            if (nativePointer == IntPtr.Zero)
            {
                throw new NullReferenceException();
            }

            PDFLibrary.AddRef("PDFAction");

            m_Source   = bookmark;
            m_Document = bookmark.Document;

            m_NativePointer = nativePointer;
        }
示例#15
0
        public PDFAction(PDFLink link, IntPtr nativePointer)
        {
            if (link == null)
            {
                throw new NullReferenceException();
            }
            if (nativePointer == IntPtr.Zero)
            {
                throw new NullReferenceException();
            }

            PDFLibrary.AddRef("PDFAction");

            m_Source   = link;
            m_Document = link.Page.Document;

            m_NativePointer = nativePointer;
        }
示例#16
0
文件: PDFDest.cs 项目: kimch2/Unity-1
        public PDFDest(PDFAction action, IntPtr nativePointer)
        {
            if (action == null)
            {
                throw new NullReferenceException();
            }
            if (nativePointer == IntPtr.Zero)
            {
                throw new NullReferenceException();
            }

            PDFLibrary.AddRef("PDFDest");

            m_Source   = action;
            m_Document = action.Document;

            m_NativePointer = nativePointer;
        }
示例#17
0
        protected virtual void Dispose(bool disposing)
        {
            if (!m_Disposed)
            {
                lock (PDFLibrary.nativeLock)
                {
                    if (m_NativePointer != IntPtr.Zero)
                    {
#if UNITY_WEBGL && !UNITY_EDITOR
                        PDFJS_CloseDocument(m_NativePointer.ToInt32());
#else
                        FPDF_CloseDocument(m_NativePointer);
#endif
                        m_NativePointer = IntPtr.Zero;
                    }
                }

                PDFLibrary.RemoveRef("PDFDocument");

                m_Disposed = true;
            }
        }
示例#18
0
        public PDFTextPage(PDFPage page)
        {
            if (page == null)
            {
                throw new NullReferenceException();
            }

            PDFLibrary.AddRef("PDFTextPage");

            m_Page          = page;
            m_NativePointer = FPDFText_LoadPage(m_Page.NativePointer);

            if (m_NativePointer != IntPtr.Zero)
            {
                if (s_InstanceMap.ContainsKey(m_NativePointer))
                {
                    s_InstanceMap[m_NativePointer] = s_InstanceMap[m_NativePointer] + 1;
                }
                else
                {
                    s_InstanceMap[m_NativePointer] = 1;
                }
            }
        }
示例#19
0
        public PDFSearchHandle(PDFTextPage textPage, byte[] findWhatUnicode, int startIndex,
                               MatchOption flags = MatchOption.NONE)
        {
            if (textPage == null)
            {
                throw new NullReferenceException();
            }
            if (startIndex < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            PDFLibrary.AddRef("PDFSearchHandle");

            m_TextPage = textPage;

            IntPtr unmanagedPointer = Marshal.AllocHGlobal(findWhatUnicode.Length);

            Marshal.Copy(findWhatUnicode, 0, unmanagedPointer, findWhatUnicode.Length);

            m_NativePointer = FPDFText_FindStart(textPage.NativePointer, unmanagedPointer, (int)flags, startIndex);

            Marshal.FreeHGlobal(unmanagedPointer);
        }
示例#20
0
        /// <summary>
        /// Open PDF Document with the specified byte array.
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="password">Can be null or empty</param>
        public PDFDocument(byte[] buffer, string password)
        {
            PDFLibrary.AddRef("PDFDocument");

            CommonInit(buffer, password);
        }
示例#21
0
 public PDFRenderer()
 {
     PDFLibrary.AddRef("PDFRenderer");
 }