static public void LoadStampFromTheImageFile(Form1 Parent) { if (Parent.m_CurDoc == null) { Document.CreateNewDoc(Parent); } //Loading image file IAFS_Inst afsInst = (IAFS_Inst)Parent.m_pxcInst.GetExtension("AFS"); string sPath = System.Environment.CurrentDirectory + "\\Images\\run_24.png"; IAFS_Name name = afsInst.DefaultFileSys.StringToName(sPath); int openFileFlags = (int)(AFS_OpenFileFlags.AFS_OpenFile_Read | AFS_OpenFileFlags.AFS_OpenFile_ShareRead); IAFS_File destFile = afsInst.DefaultFileSys.OpenFile(name, openFileFlags); //Creating new collection IPXC_StampsCollection sc = Parent.m_pxcInst.StampsManager.CreateEmptyCollection("My Stamps"); IPXC_StampInfo si = sc.AddStamp(destFile, "My Stamp"); IPXC_Pages pages = Parent.m_CurDoc.Pages; IPXC_Page firstPage = pages[0]; PXC_Rect rcPB = firstPage.get_Box(PXC_BoxType.PBox_PageBox); //Creating stamp annotation IPXS_Inst pSInt = (IPXS_Inst)Parent.m_pxcInst.GetExtension("PXS"); uint nStamp = pSInt.StrToAtom("Stamp"); double nHeight = 0; double nWidth = 0; si.GetSize(out nWidth, out nHeight); //Increasing width and height by 20 PXC_Rect rc; //Annotation rectangle rc.left = 0; rc.right = nWidth * 20; rc.top = rcPB.top; rc.bottom = rc.top - nHeight * 20; IPXC_Annotation annot = firstPage.InsertNewAnnot(nStamp, ref rc, 0); IPXC_AnnotData_Stamp stampData = (IPXC_AnnotData_Stamp)annot.Data; stampData.set_BBox(rc); //Stamp rectangle boundaries stampData.SetStampName(si.ID); annot.Data = stampData; Marshal.ReleaseComObject(firstPage); Marshal.ReleaseComObject(pages); }
static public void LoadStampsCollectionFromFile(Form1 Parent) { if (Parent.m_CurDoc == null) { Document.CreateNewDoc(Parent); } //Loading stamp collection from stamp file IAFS_Inst afsInst = (IAFS_Inst)Parent.m_pxcInst.GetExtension("AFS"); string sPath = System.Environment.CurrentDirectory + "\\Documents\\MyStamps.pdf"; IAFS_Name name = afsInst.DefaultFileSys.StringToName(sPath); int openFileFlags = (int)(AFS_OpenFileFlags.AFS_OpenFile_Read | AFS_OpenFileFlags.AFS_OpenFile_ShareRead); IAFS_File destFile = afsInst.DefaultFileSys.OpenFile(name, openFileFlags); IPXC_StampsCollection sc = Parent.m_pxcInst.StampsManager.LoadCollection(destFile); //Placing stamp from the loaded collection IPXC_Pages pages = Parent.m_CurDoc.Pages; IPXC_Page firstPage = pages[0]; PXC_Rect rcPB = firstPage.get_Box(PXC_BoxType.PBox_PageBox); IPXC_StampInfo si = sc[0]; //getting stamp by index - they are sorted by name //Creating stamp annotation IPXS_Inst pSInt = (IPXS_Inst)Parent.m_pxcInst.GetExtension("PXS"); uint nStamp = pSInt.StrToAtom("Stamp"); double nHeight = 0; double nWidth = 0; si.GetSize(out nWidth, out nHeight); PXC_Rect rc; //Annotation rectangle rc.left = 0; rc.right = nWidth; rc.top = rcPB.top; rc.bottom = rc.top - nHeight; IPXC_Annotation annot = firstPage.InsertNewAnnot(nStamp, ref rc, 0); IPXC_AnnotData_Stamp stampData = (IPXC_AnnotData_Stamp)annot.Data; stampData.set_BBox(rc); //Stamp rectangle boundaries stampData.SetStampName(si.ID); annot.Data = stampData; Marshal.ReleaseComObject(firstPage); Marshal.ReleaseComObject(pages); }