static public int AddActionsGoToR(Form1 Parent) { if (Parent.m_CurDoc == null) { Document.CreateNewDoc(Parent); } IPXC_Bookmark bookmark = null; if (Parent.SelectedBookmarkNode == null) { bookmark = Parent.m_CurDoc.BookmarkRoot.AddNewChild(true); } else { bookmark = Parent.SelectedBookmarkNode.m_Bookmark.AddNewSibling(false); } IPXC_ActionsList aList = Parent.m_CurDoc.CreateActionsList(); bookmark.Title = "GoToR Action"; bookmark.Style = PXC_BookmarkStyle.BookmarkFont_Normal; PXC_Destination dest = new PXC_Destination(); dest.nPageNum = 2; dest.nNullFlags = 4 | 8; dest.nType = PXC_DestType.Dest_XYZ; double[] point = { 20, 30, 0, 0 }; dest.dValues = point; string sFilePath = System.Environment.CurrentDirectory + "\\Documents\\FeatureChartEU.pdf"; aList.AddGotoR(sFilePath, dest); bookmark.Actions = aList; return((int)Form1.eFormUpdateFlags.efuf_Bookmarks); }
static public int AddActionsGoToE(Form1 Parent) { if (Parent.m_CurDoc == null) { Document.CreateNewDoc(Parent); } IPXC_Bookmark bookmark = null; if (Parent.SelectedBookmarkNode == null) { bookmark = Parent.m_CurDoc.BookmarkRoot.AddNewChild(true); } else { bookmark = Parent.SelectedBookmarkNode.m_Bookmark.AddNewSibling(false); } IPXS_Inst pxsInst = Parent.m_pxcInst.GetExtension("PXS"); uint atomGoToE = pxsInst.StrToAtom("GoToE"); IPXC_NameTree attachments = Parent.m_CurDoc.GetNameTree("EmbeddedFiles"); IPXS_PDFVariant var = null; try { var = attachments.Lookup("FeatureChartEU.pdf"); } catch (Exception) { string sFilePath = System.Environment.CurrentDirectory + "\\Documents\\FeatureChartEU.pdf"; IPXC_FileSpec fileSpec = Parent.m_CurDoc.CreateEmbeddFile(sFilePath); IPXC_EmbeddedFileStream EFS = fileSpec.EmbeddedFile; EFS.UpdateFromFile2(sFilePath); var = fileSpec.PDFObject; } attachments.Add("FeatureChartEU.pdf", var); IPXC_Action_Goto actionGoToE = Parent.m_pxcInst.GetActionHandler(atomGoToE).CreateEmptyAction(atomGoToE, Parent.m_CurDoc) as IPXC_Action_Goto; IPXC_GoToETargetPath targetPath = actionGoToE.TargetPath; IPXC_GoToETargetItem targetItem = targetPath.InsertNew(); targetItem.FileName = "FeatureChartEU.pdf"; targetItem = targetPath.InsertNew(); targetItem.FileName = "MyStamps.pdf"; targetItem = targetPath.InsertNew(); targetItem.AnnotIndex = 0; targetItem.PageNumber = 0; IPXC_ActionsList aList = Parent.m_CurDoc.CreateActionsList(); bookmark.Title = "GoToE Action"; bookmark.Style = PXC_BookmarkStyle.BookmarkFont_Normal; aList.Insert(0, actionGoToE); bookmark.Actions = aList; Marshal.ReleaseComObject(attachments); return((int)Form1.eFormUpdateFlags.efuf_Bookmarks | (int)Form1.eFormUpdateFlags.efuf_Attachments); }
static public int AddActionJS(Form1 Parent) { if (Parent.m_CurDoc == null) { Document.CreateNewDoc(Parent); } IPXC_Bookmark bookmark = null; if (Parent.SelectedBookmarkNode == null) { bookmark = Parent.m_CurDoc.BookmarkRoot.AddNewChild(true); } else { bookmark = Parent.SelectedBookmarkNode.m_Bookmark.AddNewSibling(false); } IPXC_ActionsList aList = Parent.m_CurDoc.CreateActionsList(); bookmark.Title = "Java Script Action"; bookmark.Style = PXC_BookmarkStyle.BookmarkFont_Normal; string sJS = "app.alert(\"Hello world!\", 3);"; aList.AddJavaScript(sJS); bookmark.Actions = aList; return((int)Form1.eFormUpdateFlags.efuf_Bookmarks); }
static public int AddActionNamed(Form1 Parent) { if (Parent.m_CurDoc == null) { Document.CreateNewDoc(Parent); } IPXC_Bookmark bookmark = null; if (Parent.SelectedBookmarkNode == null) { bookmark = Parent.m_CurDoc.BookmarkRoot.AddNewChild(true); } else { bookmark = Parent.SelectedBookmarkNode.m_Bookmark.AddNewSibling(false); } IPXS_Inst pxsInst = Parent.m_pxcInst.GetExtension("PXS"); uint atomNamed = pxsInst.StrToAtom("Named"); IPXC_Action_Named actionNamed = Parent.m_pxcInst.GetActionHandler(atomNamed).CreateEmptyAction(atomNamed, Parent.m_CurDoc) as IPXC_Action_Named; actionNamed.CmdName = "NextPage"; IPXC_ActionsList aList = Parent.m_CurDoc.CreateActionsList(); bookmark.Title = "Execute Command Action"; bookmark.Style = PXC_BookmarkStyle.BookmarkFont_Normal; aList.Insert(0, actionNamed); bookmark.Actions = aList; return((int)Form1.eFormUpdateFlags.efuf_Bookmarks); }
static public int AddActionLaunch(Form1 Parent) { if (Parent.m_CurDoc == null) { Document.CreateNewDoc(Parent); } IPXC_Bookmark bookmark = null; if (Parent.SelectedBookmarkNode == null) { bookmark = Parent.m_CurDoc.BookmarkRoot.AddNewChild(true); } else { bookmark = Parent.SelectedBookmarkNode.m_Bookmark.AddNewSibling(false); } IPXC_ActionsList aList = Parent.m_CurDoc.CreateActionsList(); bookmark.Title = "Launch Action"; bookmark.Style = PXC_BookmarkStyle.BookmarkFont_Normal; string sFilePath = System.Environment.CurrentDirectory + "\\Documents\\FeatureChartEU.pdf"; aList.AddLaunch(sFilePath); bookmark.Actions = aList; return((int)Form1.eFormUpdateFlags.efuf_Bookmarks); }
static public int AddActionURI(Form1 Parent) { if (Parent.m_CurDoc == null) { Document.CreateNewDoc(Parent); } IPXC_Bookmark bookmark = null; if (Parent.SelectedBookmarkNode == null) { bookmark = Parent.m_CurDoc.BookmarkRoot.AddNewChild(true); } else { bookmark = Parent.SelectedBookmarkNode.m_Bookmark.AddNewSibling(false); } IPXC_ActionsList aList = Parent.m_CurDoc.CreateActionsList(); bookmark.Title = "URI Action"; bookmark.Style = PXC_BookmarkStyle.BookmarkFont_Normal; string sFilePath = "https://www.tracker-software.com"; aList.AddURI(sFilePath); bookmark.Actions = aList; return((int)Form1.eFormUpdateFlags.efuf_Bookmarks); }
static public int AddActionsGoTo(Form1 Parent) { if (Parent.m_CurDoc == null) { Document.CreateNewDoc(Parent); } IPXC_Bookmark bookmark = null; if (Parent.SelectedBookmarkNode == null) { bookmark = Parent.m_CurDoc.BookmarkRoot.AddNewChild(true); } else { bookmark = Parent.SelectedBookmarkNode.m_Bookmark.AddNewSibling(false); } IPXC_ActionsList aList = Parent.m_CurDoc.CreateActionsList(); bookmark.Title = "GoTo Action"; bookmark.Style = PXC_BookmarkStyle.BookmarkFont_Normal; PXC_Destination dest = new PXC_Destination(); dest.nPageNum = Parent.CurrentPage; dest.nNullFlags = 4 | 8; dest.nType = PXC_DestType.Dest_XYZ; double[] point = { 20, 30, 0, 0 }; dest.dValues = point; aList.AddGoto(dest); bookmark.Actions = aList; return((int)Form1.eFormUpdateFlags.efuf_Bookmarks); }
static public int MoveDownSelectedBookmark(Form1 Parent) { if (Parent.m_CurDoc == null) { return(0); } if (Parent.SelectedBookmarkNode == null) { MessageBox.Show("There are no selected bookmarks - please select a bookmark from the Bookmarks Tree", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(0); } IPXC_Bookmark pxcBookmark = Parent.SelectedBookmarkNode.m_Bookmark; if (pxcBookmark == Parent.m_CurDoc.BookmarkRoot.LastChild) { return(0); } if (pxcBookmark == pxcBookmark.Parent.LastChild) { IPXC_Bookmark parent = pxcBookmark.Parent; pxcBookmark.Unlink(); parent.AddSibling(pxcBookmark, false); } else { IPXC_Bookmark nextBookmark = pxcBookmark.Next; pxcBookmark.Unlink(); nextBookmark.AddSibling(pxcBookmark, false); } return((int)Form1.eFormUpdateFlags.efuf_Bookmarks); }
static public int AddNewDictionaryToDocumentsRoot(Form1 Parent) { if (Parent.m_CurDoc == null) { Document.OpenDocFromStringPath(Parent); } IPXS_Inst pxsInst = (IPXS_Inst)Parent.m_pxcInst.GetExtension("PXS"); //Getting structure document IPXS_Document structDoc = Parent.m_CurDoc.CosDocument; //Locking document for write structDoc.LockDocumentExclusive(); //Creating new indirect variant of the Dictionary type that will hold some elements IPXS_PDFVariant varHolder = pxsInst.NewVar_Dict(structDoc, true); //Adding our newly created variant to the root dictionary structDoc.Root.Dict_Set("TestDataHolder", varHolder); //Creating an item that will hold some custom data and will link to the bookmarks root IPXS_PDFVariant varBookItem = pxsInst.NewVar_Dict(structDoc, true); //Adding that item to the holder dictionary varHolder.Dict_Set("BookmarkItem", varBookItem); //Setting some custom fields for this item varBookItem.Dict_SetBool("IsRoot", true); varBookItem.Dict_SetName("CustName", "Root Link"); varBookItem.Dict_SetInt("CustInt", 123); //Setting a link to the bookmark's Root object IPXC_Bookmark root = Parent.m_CurDoc.BookmarkRoot; //If we have at least one bookmark in the document, then the root won't be null if (root != null) { varBookItem.Dict_Set("BookmarkLink", root.PDFObject); } //Unlocking the document, since we've finished all of the work with it structDoc.UnlockDocumentExclusive(); return((int)Form1.eFormUpdateFlags.efuf_All); }
static public int AddChildBookmark(Form1 Parent) { if (Parent.m_CurDoc == null) { return(0); } IPXC_Bookmark bookmark = null; if (Parent.SelectedBookmarkNode == null) { bookmark = Parent.m_CurDoc.BookmarkRoot.AddNewChild(true); } else { bookmark = Parent.SelectedBookmarkNode.m_Bookmark.AddNewChild((Parent.SelectedBookmarkNode.m_Bookmark.ChildrenCount > 0)); } IPXC_ActionsList aList = Parent.m_CurDoc.CreateActionsList(); bookmark.Title = (Parent.CurrentPage + 1) + " page"; bookmark.Style = PXC_BookmarkStyle.BookmarkFont_Normal; PXC_Destination dest = new PXC_Destination(); dest.nPageNum = Parent.CurrentPage; dest.nNullFlags = 0; dest.nType = PXC_DestType.Dest_FitR; IPXC_Pages pages = Parent.m_CurDoc.Pages; IPXC_Page page = pages[Parent.CurrentPage]; PXC_Rect rc = page.get_Box(PXC_BoxType.PBox_BBox); double[] rect = { rc.left, rc.bottom, rc.right, rc.top }; dest.dValues = rect; aList.AddGoto(dest); bookmark.Actions = aList; Marshal.ReleaseComObject(page); Marshal.ReleaseComObject(pages); return((int)Form1.eFormUpdateFlags.efuf_Bookmarks); }
static public int RemoveSelectedBookmarkWithoutChildren(Form1 Parent) { if (Parent.m_CurDoc == null) { return(0); } if (Parent.SelectedBookmarkNode == null) { MessageBox.Show("There are no selected bookmarks - please select a bookmark from the Bookmarks Tree", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(0); } IPXC_Bookmark selBookmark = Parent.SelectedBookmarkNode.m_Bookmark; while (selBookmark.ChildrenCount > 0) { IPXC_Bookmark childBookmark = selBookmark.FirstChild; selBookmark.FirstChild.Unlink(); selBookmark.AddSibling(childBookmark, false); } selBookmark.Unlink(); return((int)Form1.eFormUpdateFlags.efuf_Bookmarks); }