示例#1
0
        static public void ExportAllFieldsOnPage(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.OpenDocumentFromStream(Parent);
                Parent.UpdateControlsFromDocument(0);
                Parent.UpdatePreviewFromCurrentDocument();
            }
            //Getting current page
            IPXC_Pages pages = Parent.m_CurDoc.Pages;
            IPXC_Page  Page  = pages[Parent.CurrentPage];

            //Locking CosDocument for reading
            Parent.m_CurDoc.CosDocument.LockDocument();
            //Creating new array that will store the variants of the needed form fields
            IPXS_Inst       pxsInst = (IPXS_Inst)Parent.m_pxcInst.GetExtension("PXS");
            IPXS_PDFVariant arrVar  = pxsInst.NewVar_Array(0, Parent.m_CurDoc.CosDocument);
            //Get AcroForm from Document
            IPXC_AcroForm acroForm = Parent.m_CurDoc.AcroForm;

            for (uint i = 0; i < acroForm.FieldsCount; i++)
            {
                IPXC_FormField field = acroForm.Field[i];
                if (field == null)
                {
                    continue;
                }
                arrVar.Arr_Insert(field.PDFObject);
                Marshal.ReleaseComObject(field);
            }
            Parent.m_CurDoc.CosDocument.UnlockDocument();

            Marshal.ReleaseComObject(Page);
            Marshal.ReleaseComObject(pages);
            if (arrVar.Count == 0)
            {
                return;
            }
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter          = "FDF Documents (*.fdf)|*.fdf|XFDF Documents (*.xfdf)|*.xfdf|HTML Documents (*.html)|*.hrml|XML Documents (*.xml)|*.xml";
            sfd.FilterIndex     = 4;
            sfd.CheckPathExists = true;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                IAFS_Inst afsInst = (IAFS_Inst)Parent.m_pxcInst.GetExtension("AFS");
                IAFS_Name name    = afsInst.DefaultFileSys.StringToName(sfd.FileName);
                string    sExt    = Path.GetExtension(sfd.FileName).ToLower();
                sExt = sExt.TrimStart('.');
                acroForm.Export(name, sExt, arrVar, true, (uint)PXC_ExportFormFlags.FormExport_Default);
                Process.Start("explorer.exe", "/select, \"" + sfd.FileName + "\"");
            }
        }
示例#2
0
        static public void FlattenAllFieldsOnPage(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.OpenDocumentFromStream(Parent);
                Parent.UpdateControlsFromDocument(0);
                Parent.UpdatePreviewFromCurrentDocument();
            }
            //Getting current page
            IPXC_Pages pages = Parent.m_CurDoc.Pages;
            IPXC_Page  Page  = pages[Parent.CurrentPage];
            //Get AcroForm from Document
            IPXC_AcroForm acroForm = Parent.m_CurDoc.AcroForm;

            acroForm.FlattenAllFields();

            Marshal.ReleaseComObject(Page);
            Marshal.ReleaseComObject(pages);
        }
示例#3
0
        static public void FlattenFieldsByName(Form1 Parent)
        {
            if (Parent.m_CurDoc == null)
            {
                Document.OpenDocumentFromStream(Parent);
                Parent.UpdateControlsFromDocument(0);
                Parent.UpdatePreviewFromCurrentDocument();
            }
            //Get AcroForm from Document
            IPXC_AcroForm acroForm = Parent.m_CurDoc.AcroForm;

            for (int i = (int)acroForm.FieldsCount - 1; i >= 0; i--)
            {
                IPXC_FormField field = acroForm.Field[(uint)i];
                if (field == null)
                {
                    continue;
                }
                acroForm.FlattenField(field.FullName);
                Marshal.ReleaseComObject(field);
            }
        }