Esempio n. 1
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();
                }
            }
        }
        public void HandleLaunchAction(IPDFDevice device, string filePath)
        {
#if !UNITY_WEBGL
            if (filePath.Trim().Substring(filePath.Length - 4).ToLower().Contains("pdf"))
            {
                device.LoadDocumentWithFile(filePath, "", 0);
            }
#endif
        }
Esempio n. 3
0
        public static void ExecuteAction(IPDFDeviceActionHandler actionHandler, IPDFDevice device, PDFAction action)
        {
            if (action != null)
            {
                PDFAction.ActionType type = action.GetActionType();

                switch (type)
                {
                case PDFAction.ActionType.Unsupported:
                    break;

                case PDFAction.ActionType.GoTo:
                    PDFDest dest = action.GetDest();
                    actionHandler.HandleGotoAction(device, dest.PageIndex);
                    break;

                case PDFAction.ActionType.RemoteGoTo:
                    string resolvedFilePath = actionHandler.HandleRemoteGotoActionPathResolving(device,
                                                                                                action.GetFilePath());

#if !((UNITY_4_6 || UNITY_4_7) && UNITY_WINRT)
                    if (File.Exists(resolvedFilePath))
                    {
                        string password = actionHandler.HandleRemoteGotoActionPasswordResolving(device,
                                                                                                resolvedFilePath);
                        PDFDocument newDocument = new PDFDocument(resolvedFilePath, password);

                        if (newDocument.IsValid)
                        {
                            actionHandler.HandleRemoteGotoActionResolved(device, newDocument,
                                                                         action.GetDest().PageIndex);
                        }
                        else
                        {
                            actionHandler.HandleRemoteGotoActionUnresolved(device, resolvedFilePath);
                        }
                    }
                    else
#endif
                    actionHandler.HandleRemoteGotoActionUnresolved(device, resolvedFilePath);


                    break;

                case PDFAction.ActionType.Uri:
                    actionHandler.HandleUriAction(device, action.GetURIPath());
                    break;

                case PDFAction.ActionType.Launch:
                    actionHandler.HandleLaunchAction(device, action.GetFilePath());
                    break;
                }
            }
        }
        public void HandleUriAction(IPDFDevice device, string uri)
        {
            if (uri.Trim().Substring(uri.Length - 4).ToLower().Contains("pdf"))
            {
#if !UNITY_WEBGL
                device.LoadDocumentFromWeb(uri, "", 0);
#endif
            }
            else if (device.AllowOpenURL)
            {
                if (uri.Trim().ToLowerInvariant().StartsWith("http:") ||
                    uri.Trim().ToLowerInvariant().StartsWith("https:") ||
                    uri.Trim().ToLowerInvariant().StartsWith("ftp:"))
                {
                    Application.OpenURL(uri);
                }
            }
        }
Esempio n. 5
0
        public static void ExecuteBookmarkAction(IPDFDevice device, PDFBookmark bookmark)
        {
            if (device.BookmarksActionHandler != null)
            {
                PDFDest dest = bookmark.GetDest();

                if (dest != null)
                {
                    device.BookmarksActionHandler.HandleGotoAction(device, dest.PageIndex);
                }
                else
                {
                    PDFAction action = bookmark.GetAction();

                    if (action != null)
                    {
                        ExecuteAction(device.BookmarksActionHandler, device, action);
                    }
                }
            }
        }
Esempio n. 6
0
        public static void ExecuteLinkAction(IPDFDevice device, PDFLink link)
        {
            if (device.LinksActionHandler != null)
            {
                PDFDest dest = link.GetDest();

                if (dest != null)
                {
                    device.LinksActionHandler.HandleGotoAction(device, dest.PageIndex);
                }
                else
                {
                    PDFAction action = link.GetAction();

                    if (action != null)
                    {
                        ExecuteAction(device.LinksActionHandler, device, action);
                    }
                }
            }
        }
 public void HandleGotoAction(IPDFDevice device, int pageIndex)
 {
     device.GoToPage(pageIndex);
 }
 public void HandleUnsuportedAction(IPDFDevice device)
 {
     // ...
 }
 public void HandleRemoteGotoActionUnresolved(IPDFDevice device, string resolvedFilePath)
 {
     // ...
 }
        public void HandleRemoteGotoActionResolved(IPDFDevice device, PDFDocument document, int pageIndex)
        {
#if !UNITY_WEBGL
            device.LoadDocument(document, "", pageIndex);
#endif
        }
 public string HandleRemoteGotoActionPathResolving(IPDFDevice device, string filePath)
 {
     return(filePath);
 }
 public string HandleRemoteGotoActionPasswordResolving(IPDFDevice device, string resolvedFilePath)
 {
     return("");
 }
Esempio n. 13
0
 /// <summary>
 /// Return the root bookmark of the document.
 /// </summary>
 /// <param name="device">Pass the device that will receive bookmarks action</param>
 /// <returns></returns>
 public PDFBookmark GetRootBookmark(IPDFDevice device)
 {
     return(new PDFBookmark(this, null, IntPtr.Zero, device));
 }