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 RemoveAttachment(Form1 Parent) { if (Parent.m_CurDoc == null) { return(0); } if (Parent.AttachmentView.SelectedItems.Count == 0) { MessageBox.Show("Please select attachment from the Attachments list.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(0); } Form1.ListItemAttachment currentAnnot = Parent.AttachmentView.SelectedItems[0] as Form1.ListItemAttachment; if (currentAnnot.SubItems[currentAnnot.SubItems.Count - 1].Text == "Embedded File Item") { IPXC_NameTree attachments = Parent.m_CurDoc.GetNameTree("EmbeddedFiles"); attachments.Remove(currentAnnot.SubItems[0].Text); return((int)Form1.eFormUpdateFlags.efuf_Attachments | (int)Form1.eFormUpdateFlags.efuf_Annotations); } IPXC_Pages pages = Parent.m_CurDoc.Pages; IPXC_Page page = pages[(uint)(currentAnnot.m_nPageNumber)]; page.RemoveAnnots((uint)currentAnnot.m_nIndexOnPage, 1); Marshal.ReleaseComObject(page); Marshal.ReleaseComObject(pages); return((int)Form1.eFormUpdateFlags.efuf_Attachments | (int)Form1.eFormUpdateFlags.efuf_Annotations); }
static public int ChangeAttachmentsDescription(Form1 Parent) { if (Parent.m_CurDoc == null) { return(0); } if (Parent.AttachmentView.SelectedItems.Count == 0) { MessageBox.Show("Please select attachment from the Attachments list.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(0); } Form1.ListItemAttachment currentAnnot = Parent.AttachmentView.SelectedItems[0] as Form1.ListItemAttachment; if (currentAnnot.SubItems[currentAnnot.SubItems.Count - 1].Text == "Embedded File Item") { IPXC_NameTree attachments = Parent.m_CurDoc.GetNameTree("EmbeddedFiles"); IPXS_PDFVariant pdfVariant = attachments.Lookup(currentAnnot.SubItems[0].Text); IPXC_FileSpec fileSpec = Parent.m_CurDoc.GetFileSpecFromVariant(pdfVariant); fileSpec.Description = "Description"; Marshal.ReleaseComObject(attachments); return((int)Form1.eFormUpdateFlags.efuf_Attachments | (int)Form1.eFormUpdateFlags.efuf_Annotations); } IPXC_Pages pages = Parent.m_CurDoc.Pages; IPXC_Annotation annotFileAttach = pages[(uint)currentAnnot.m_nPageNumber].GetAnnot((uint)currentAnnot.m_nIndexOnPage); IPXC_AnnotData_FileAttachment fileAttachment = annotFileAttach.Data as IPXC_AnnotData_FileAttachment; IPXC_FileSpec annotAttachFileSpec = fileAttachment.FileAttachment; annotAttachFileSpec.Description = "Description"; return((int)Form1.eFormUpdateFlags.efuf_Attachments | (int)Form1.eFormUpdateFlags.efuf_Annotations); }
static public int RemoveNamedDest(Form1 Parent) { if (Parent.m_CurDoc == null) { return(0); } if (Parent.SelectedNameDest_Item == null) { return(0); } IPXC_NameTree nameTree = Parent.m_CurDoc.GetNameTree("Dests"); nameTree.Remove(Parent.SelectedNameDest_Item.Text); Marshal.ReleaseComObject(nameTree); return((int)Form1.eFormUpdateFlags.efuf_NamedDests); }
static public int AddAttachment(Form1 Parent) { if (Parent.m_CurDoc == null) { Document.CreateNewDoc(Parent); } IAFS_Inst afsInst = Parent.m_pxcInst.GetExtension("AFS"); IPXC_NameTree attachments = Parent.m_CurDoc.GetNameTree("EmbeddedFiles"); IPXS_PDFVariant var = null; string path = Environment.CurrentDirectory + "\\Documents\\FeatureChartEU.pdf"; IPXC_FileSpec fileSpec = Parent.m_CurDoc.CreateEmbeddFile(path); IPXC_EmbeddedFileStream embeddedFileStream = fileSpec.EmbeddedFile;; embeddedFileStream.UpdateFromFile2(path); var = fileSpec.PDFObject; attachments.Add("FeatureChartEU.pdf", var); Marshal.ReleaseComObject(attachments); return((int)Form1.eFormUpdateFlags.efuf_Attachments | (int)Form1.eFormUpdateFlags.efuf_Annotations); }