public static void Run()
        {
            try
            {
                // ExStart:GetButtonOptionValue
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

                // Create Form Object
                Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();

                // Open Document
                pdfForm.BindPdf(dataDir + "FormField.pdf");

                // Get button option values
                var optionValues = pdfForm.GetButtonOptionValues("Gender");

                IDictionaryEnumerator optionValueEnumerator = optionValues.GetEnumerator();

                while (optionValueEnumerator.MoveNext())
                {
                    Console.WriteLine("Key : {0} , Value : {1} ", optionValueEnumerator.Key, optionValueEnumerator.Value);
                }
                // ExEnd:GetButtonOptionValue
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static void Run()
        {
            // ExStart:GetFormFieldValue
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            // Create Form Object
            Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();

            // Open Document
            pdfForm.BindPdf(dataDir + "FormField.pdf");

            // Get form field facade
            FormFieldFacade fieldFacade = pdfForm.GetFieldFacade("textfield");

            // Get facade values
            Console.WriteLine("Alignment : {0} ", fieldFacade.Alignment);
            Console.WriteLine("Background Color : {0} ", fieldFacade.BackgroundColor);
            Console.WriteLine("Border Color : {0} ", fieldFacade.BorderColor);
            Console.WriteLine("Border Style : {0} ", fieldFacade.BorderStyle);
            Console.WriteLine("Border Width : {0} ", fieldFacade.BorderWidth);
            Console.WriteLine("Box : {0} ", fieldFacade.Box);
            Console.WriteLine("Caption : {0} ", fieldFacade.Caption);
            Console.WriteLine("Font Name : {0} ", fieldFacade.Font);
            Console.WriteLine("Font Size : {0} ", fieldFacade.FontSize);
            Console.WriteLine("Page Number : {0} ", fieldFacade.PageNumber);
            Console.WriteLine("Text Color : {0} ", fieldFacade.TextColor);
            Console.WriteLine("Text Encoding : {0} ", fieldFacade.TextEncoding);
            // ExEnd:GetFormFieldValue
        }
        public static void Run()
        {
            // ExStart:IdentifyFormFields
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // First a input pdf file should be assigned
            Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form(dataDir + "FilledForm.pdf");
            // Get all field names
            String[] allfields = form.FieldNames;
            // Create an array which will hold the location coordinates of Form fields
            System.Drawing.Rectangle[] box = new System.Drawing.Rectangle[allfields.Length];
            for (int i = 0; i < allfields.Length; i++)
            {
                // Get the appearance attributes of each field, consequtively
                FormFieldFacade facade = form.GetFieldFacade(allfields[i]);
                // Box in FormFieldFacade class holds field's location.
                box[i] = facade.Box;
            }
            form.Save(dataDir + "IdentifyFormFields_1_out.pdf");

            Document doc = new Document(dataDir + "FilledForm - 2.pdf");
            // Now we need to add a textfield just upon the original one
            FormEditor editor = new FormEditor(doc);
            for (int i = 0; i < allfields.Length; i++)
            {
                // Add text field beneath every existing form field
                editor.AddField(FieldType.Text, "TextField" + i, allfields[i], 1, box[i].Left, box[i].Top, box[i].Left + 50, box[i].Top + 10);
            }
            // Close the document
            editor.Save(dataDir + "IdentifyFormFields_out.pdf");
            // ExEnd:IdentifyFormFields                      
        }
        public static void Run()
        {
            // ExStart:DifferenceBetweenFile
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            // First a input pdf file should be assigned
            Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form(dataDir + "FilledForm.pdf");
            // Get all field names
            String[] allfields = form.FieldNames;
            // Create an array which will hold the location coordinates of Form fields
            System.Drawing.Rectangle[] box = new System.Drawing.Rectangle[allfields.Length];
            for (int i = 0; i < allfields.Length; i++)
            {
                // Get the appearance attributes of each field, consequtively
                FormFieldFacade facade = form.GetFieldFacade(allfields[i]);
                // Box in FormFieldFacade class holds field's location.
                box[i] = facade.Box;
            }
            form.Save(dataDir + "DifferenceBetweenFile_out.pdf");

            Document document = new Document(dataDir + "FilledForm - 2.pdf");
            // Now we need to add a textfield just upon the original one
            FormEditor editor = new FormEditor(document);

            for (int i = 0; i < allfields.Length; i++)
            {
                // Add text field beneath every existing form field
                editor.AddField(FieldType.Text, "TextField" + i, allfields[i], 1, box[i].Left, box[i].Top, box[i].Left + 50, box[i].Top + 10);
            }
            // Close the document
            editor.Save(dataDir + "DifferenceBetweenFile_out.pdf");
            // ExEnd:DifferenceBetweenFile
        }
        public static void Run()
        {
            try
            {
                // ExStart:GetButtonOptionValue
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

                // Create Form Object
                Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();

                // Open Document
                pdfForm.BindPdf(dataDir + "FormField.pdf");

                // Get button option values
                var optionValues = pdfForm.GetButtonOptionValues("Gender");

                IDictionaryEnumerator optionValueEnumerator = optionValues.GetEnumerator();

                while (optionValueEnumerator.MoveNext())
                    Console.WriteLine("Key : {0} , Value : {1} ", optionValueEnumerator.Key, optionValueEnumerator.Value);
                // ExEnd:GetButtonOptionValue
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #6
0
 public static Aspose.Pdf.Facades.Form ReadPDFForm(Aspose.Pdf.Facades.Form pdfForm)
 {
     string[] fields = pdfForm.FieldNames;
     foreach (String field in fields)
     {
         LoggerService.WriteLog(field);
     }
     
     return pdfForm;
 }
 public static void GetMaxFieldLimitUsingFacades()
 {
     // ExStart:GetMaxFieldLimitUsingFacades
     // The path to the documents directory.
     string dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
     // Getting maximum field limit using Facades
     Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
     form.BindPdf(dataDir + "FieldLimit.pdf");
     Console.WriteLine("Limit: " + form.GetFieldLimit("textbox1"));
     // ExEnd:GetMaxFieldLimitUsingFacades
 }
        public static void GetMaxFieldLimitUsingFacades()
        {
            // ExStart:GetMaxFieldLimitUsingFacades
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Forms();

            // Getting maximum field limit using Facades
            Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
            form.BindPdf(dataDir + "FieldLimit.pdf");
            Console.WriteLine("Limit: " + form.GetFieldLimit("textbox1"));
            // ExEnd:GetMaxFieldLimitUsingFacades
        }
 public static void PreserveRightsUsingFormClass()
 {
     // ExStart:PreserveRightsUsingFormClass
     // The path to the documents directory.
     string dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
     // Input and output file paths are equal, this forces incremental update when form saved.
     Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form(dataDir + "input.pdf");
     // Fill value in form field
     form.FillField("topmostSubform[0].Page1[0].f1_29_0_[0]", "Nayyer");
     // Save updated document
     form.Save(dataDir + "PreserveRightsUsingFormClass_out.pdf");
     // ExEnd:PreserveRightsUsingFormClass
 }       
        public static void Run()
        {
            // ExStart:GetFieldValue
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();
            // Open Document
            pdfForm.BindPdf(dataDir + "input.pdf");

            // Get field value
            Console.WriteLine("Field Value : {0} ", pdfForm.GetField("textfield"));
            // ExEnd:GetFieldValue
        }
Example #11
0
        public static void PreserveRightsUsingFormClass()
        {
            // ExStart:PreserveRightsUsingFormClass
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Forms();

            // Input and output file paths are equal, this forces incremental update when form saved.
            Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form(dataDir + "input.pdf");
            // Fill value in form field
            form.FillField("topmostSubform[0].Page1[0].f1_29_0_[0]", "Nayyer");
            // Save updated document
            form.Save(dataDir + "PreserveRightsUsingFormClass_out_.pdf");
            // ExEnd:PreserveRightsUsingFormClass
        }
Example #12
0
        public static Boolean WritePDFForm(Aspose.Pdf.Facades.Form pdfForm,IConfiguration sampleData)
        {
            foreach (KeyValuePair<string, string> data in sampleData.AsEnumerable())
            {
                LoggerService.WriteLog(data.Key);
                LoggerService.WriteLog(data.Value);
                pdfForm.FillField(data.Key, data.Value);                
            }
            
            pdfForm.Document.Flatten();

            // Save updated file
            pdfForm.Save(Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName + "\\SampleDoc\\OutputPdfFormSample.pdf");
            return true;
        }
        public static void Run()
        {
            // ExStart:JustifyText
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            using (FileStream source = File.Open(dataDir + "Input1.pdf", FileMode.Open))
            {
                MemoryStream ms = new MemoryStream();

                // Create Form Object
                Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();

                // Open Source File
                form.BindPdf(source);

                // Fill Text Field
                form.FillField("Text1", "Thank you for using Aspose");

                // Save the document in Memory Stream
                form.Save(ms);

                ms.Seek(0, SeekOrigin.Begin);

                FileStream dest = new FileStream(dataDir + "JustifyText_out.pdf", FileMode.Create);

                // Create formEditor Object
                FormEditor formEditor = new FormEditor();

                // Open PDF from memory stream
                formEditor.BindPdf(ms);

                // Set Text Alignment as Justified
                formEditor.Facade.Alignment = FormFieldFacade.AlignJustified;

                // Decorate form field.
                formEditor.DecorateField();

                // Save te resultant file.
                formEditor.Save(dest);

                // Close file stream
                dest.Close();
            }
            // ExEnd:JustifyText
        }
        public static void Run()
        {
            // ExStart:FlattenAllFields
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();
            // Open Document
            pdfForm.BindPdf(dataDir + "input.pdf");

            // Flatten fields
            pdfForm.FlattenAllFields();

            // Save output
            pdfForm.Save(dataDir + "FlattenAllFields_out_.pdf");
            // ExEnd:FlattenAllFields
        }
        public static void Run()
        {
            // ExStart:JustifyText
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            using (FileStream source = File.Open(dataDir + "Input1.pdf", FileMode.Open))
            {
                MemoryStream ms = new MemoryStream();

                // Create Form Object
                Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();

                // Open Source File
                form.BindPdf(source);

                // Fill Text Field
                form.FillField("Text1", "Thank you for using Aspose");

                // Save the document in Memory Stream
                form.Save(ms);

                ms.Seek(0, SeekOrigin.Begin);

                FileStream dest = new FileStream(dataDir + "JustifyText_out.pdf", FileMode.Create);

                // Create formEditor Object
                FormEditor formEditor = new FormEditor();

                // Open PDF from memory stream
                formEditor.BindPdf(ms);

                // Set Text Alignment as Justified
                formEditor.Facade.Alignment = FormFieldFacade.AlignJustified;

                // Decorate form field.
                formEditor.DecorateField();

                // Save te resultant file.
                formEditor.Save(dest);

                // Close file stream
                dest.Close();
            }
            // ExEnd:JustifyText                      
        }
        public static void Run()
        {
            // ExStart:FlattenAllFields
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();
            // Open Document
            pdfForm.BindPdf(dataDir + "input.pdf");

            // Flatten fields
            pdfForm.FlattenAllFields();

            // Save output
            pdfForm.Save( dataDir + "FlattenAllFields_out.pdf");
            // ExEnd:FlattenAllFields
        }
        public static void GetCurrentValue()
        {
            // ExStart:GetCurrentValue
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            // Create Form Object
            Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();

            // Open Document
            pdfForm.BindPdf(dataDir + "FormField.pdf");

            // Get button option values
            string optionValue = pdfForm.GetButtonOptionCurrentValue("Gender");

            Console.WriteLine("Current Value : {0} ", optionValue);
            // ExEnd:GetCurrentValue
        }
Example #18
0
        public PdfModelProcessor(byte[] pdfContent)
        {
            license = new License();
            DocsPaDB.Query_DocsPAWS.ClientSideModelProcessor csmp = new DocsPaDB.Query_DocsPAWS.ClientSideModelProcessor();

            byte[] licenseContent = csmp.GetLicense("ASPOSE");
            if (licenseContent != null)
            {
                System.IO.MemoryStream licenseStream = new System.IO.MemoryStream(licenseContent, 0, licenseContent.Length);
                license.SetLicense(licenseStream);
                licenseStream.Close();
            }

            MemoryStream ms = new MemoryStream(pdfContent);

            form = new Form();
            form.BindPdf(ms);
        }
        public static void GetCurrentValue()
        {
            // ExStart:GetCurrentValue
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            // Create Form Object
            Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();

            // Open Document
            pdfForm.BindPdf(dataDir + "FormField.pdf");

            // Get button option values
            string optionValue = pdfForm.GetButtonOptionCurrentValue("Gender");

            Console.WriteLine("Current Value : {0} ", optionValue);
            // ExEnd:GetCurrentValue
        }
Example #20
0
        public static void Run()
        {
            // ExStart:FillFormFieldF
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            // Create Form Object
            Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();

            // Open Document
            pdfForm.BindPdf(dataDir + "FormField.pdf");

            // Fill the field "textfield" with "Mike".
            pdfForm.FillField("textfield", "Mike");

            // Save updated file
            pdfForm.Save(dataDir + "FillFormFieldF_out_.pdf");
            // ExEnd:FillFormFieldF
        }
        public static void Run()
        {
            // ExStart:FillFormFieldF
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            // Create Form Object
            Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();

            // Open Document
            pdfForm.BindPdf(dataDir + "FormField.pdf");

            // Fill the field "textfield" with "Mike".
            pdfForm.FillField("textfield", "Mike");                    
            
            // Save updated file
            pdfForm.Save( dataDir + "FillFormFieldF_out.pdf");
            // ExEnd:FillFormFieldF
        }
Example #22
0
        public static void Run()
        {
            // ExStart:ImportDataFromXML
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            // Open document
            Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();

            // Open xml file.
            System.IO.FileStream xmlInputStream = new FileStream(dataDir + "input.xml", FileMode.Open);

            // Import data
            form.ImportXml(xmlInputStream);

            // Close file stream
            xmlInputStream.Close();

            // Save updated document
            form.Save(dataDir + "ImportDataFromXML_out_.pdf");
            // ExEnd:ImportDataFromXML
        }
        public static void Run()
        {
            // ExStart:ImportDataFromXML
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            // Open document
            Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();        

            // Open xml file.
            System.IO.FileStream xmlInputStream = new FileStream(dataDir + "input.xml", FileMode.Open);

            // Import data
            form.ImportXml(xmlInputStream);

            // Close file stream
            xmlInputStream.Close();

            // Save updated document
            form.Save(dataDir + "ImportDataFromXML_out.pdf");
            // ExEnd:ImportDataFromXML
        }        
        public static void Run()
        {
            // ExStart:ImportDataFromXFDF
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
            // Open Document
            form.BindPdf(dataDir + "input.pdf");

            // Open xfdf file.
            System.IO.FileStream xfdfInputStream = new FileStream("student1.xfdf", FileMode.Open);

            // Import data
            form.ImportXfdf(xfdfInputStream);

            // Close file stream
            xfdfInputStream.Close();

            // Save updated document
            form.Save(dataDir + "ImportDataFromXFDF_out.pdf");
            // ExEnd:ImportDataFromXFDF
        }        
        public static void Run()
        {
            // ExStart:ExportDataToXFDF
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
            // Open Document
            form.BindPdf(dataDir + "input.pdf");

            // Create xfdf file.
            System.IO.FileStream xfdfOutputStream = new FileStream("student1.xfdf", FileMode.Create);

            // Export data
            form.ExportXfdf(xfdfOutputStream);

            // Close file stream
            xfdfOutputStream.Close();

            // Save updated document
            form.Save(dataDir + "ExportDataToXFDF_out_.pdf");
            // ExEnd:ExportDataToXFDF
        }
        public static void Run()
        {
            // ExStart:ImportDataFromPdf
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
            // Open Document
            form.BindPdf(dataDir + "input.pdf");

            // Open fdf file.
            System.IO.FileStream fdfInputStream = new FileStream(dataDir + "student.fdf", FileMode.Open);

            // Import data
            form.ImportFdf(fdfInputStream);

            // Close file stream
            fdfInputStream.Close();

            // Save updated document
            form.Save(dataDir + "ImportDataFromPdf_out.pdf");
            // ExEnd:ImportDataFromPdf
        }
        public static void Run()
        {
            // ExStart:ExportDataToPdf
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
            // Open Document
            form.BindPdf(dataDir + "input.pdf");

            // Create fdf file.
            System.IO.FileStream fdfOutputStream = new FileStream(dataDir + "student.fdf", FileMode.Create);

            // Export data
            form.ExportFdf(fdfOutputStream);

            // Close file stream
            fdfOutputStream.Close();

            // Save updated document
            form.Save(dataDir + "ExportDataToPdf_out.pdf"); 
            // ExEnd:ExportDataToPdf
        }        
        public static void Run()
        {
            // ExStart:ExportDataToXML
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            // Open document
            Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();

            form.BindPdf(dataDir + "input.pdf");

            // Create xml file.
            System.IO.FileStream xmlOutputStream = new FileStream(dataDir + "input.xml", FileMode.Create);

            // Export data
            form.ExportXml(xmlOutputStream);

            // Close file stream
            xmlOutputStream.Close();

            // Close the document
            form.Dispose();
            // ExEnd:ExportDataToXML
        }
        public static void Run()
        {
            // ExStart:ExportDataToXML
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            // Open document
            Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();

            form.BindPdf(dataDir + "input.pdf");

            // Create xml file.
            System.IO.FileStream xmlOutputStream = new FileStream( dataDir + "input.xml", FileMode.Create);

            // Export data
            form.ExportXml(xmlOutputStream);

            // Close file stream
            xmlOutputStream.Close();

            // Close the document
            form.Dispose();
            // ExEnd:ExportDataToXML
        }        
Example #30
0
        private static string CheckFields(Document doc, int pageCount, string filename, string fields, double ratio, bool licensed = true)
        {
            double marginLeft = doc.Pages[pageCount].PageInfo.Margin.Left;
            double marginTop  = doc.Pages[pageCount].PageInfo.Margin.Top;

            int fieldcounter = 0;

            Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form(doc);

            // Get values from all fields
            foreach (Field formField in doc.Form.Fields)
            {
                double lowerLeftY = (doc.Pages[pageCount].Rect.Height) - (formField.Rect.ToRect().Y + formField.Height);

                double lowerLeftX = formField.Rect.ToRect().X;
                var    fieldType  = formField.GetType().Name;             //pdfForm.GetFieldType(formField.FullName);
                var    imValue    = "";

                if (fieldType.ToString() == "CheckboxField" || fieldType.ToString() == "ComboBoxField" || fieldType.ToString() == "RadioButtonOptionField" || fieldType.ToString() == "TextBoxField")
                {
                    var value = formField.Value;

                    if (fieldType.ToString() == "TextBoxField")
                    {
                        fieldType = "Text";
                    }
                    if (fieldType.ToString() == "CheckboxField")
                    {
                        CheckboxField field = (CheckboxField)formField;
                        if (field.Parent != null)
                        {
                            imValue = field.Parent.FullName;
                        }
                        fieldType = "CheckBox";
                        if (field.Checked)
                        {
                            value = "true";
                        }
                        else
                        {
                            value = "false";
                        }
                    }
                    if (fieldType.ToString() == "RadioButtonOptionField")
                    {
                        RadioButtonOptionField field = (RadioButtonOptionField)formField;
                        RadioButtonField       rbf   = (RadioButtonField)field.Parent;

                        fieldType = "Radio";
                        if (field.Parent != null)
                        {
                            imValue = field.Parent.FullName;
                        }
                        if ((rbf.Options[field.OptionName].Index == rbf.Selected))
                        {
                            value = "true";
                        }
                        else
                        {
                            value = "false";
                        }
                    }
                    if (fieldType.ToString() == "ComboBoxField")
                    {
                        ComboBoxField field     = (ComboBoxField)formField;
                        string        optValues = value;
                        fieldType = "ComboBox";
                        foreach (Option opt in field.Options)
                        {
                            optValues = optValues + "^^^" + opt.Value;
                        }
                        value = optValues;
                    }

                    bool isRequired = pdfForm.IsRequiredField(formField.FullName);
                    //fields += "$#$" + (lowerLeftX * 2.08) * ratio + "$#$" + (lowerLeftY * 2.08) * ratio + "$#$" + (formField.Width * 2.08) * ratio + "$#$" + (formField.Height * 2.08) * ratio + "$#$" + formField.PageIndex + "$#$" + "image" + formField.PageIndex + ".png" + "$#$" + value + "$#$" + formField.DefaultAppearance.FontName + "$#$" + formField.DefaultAppearance.FontSize + "$#$" + " " + "$#$" + " " + "$#$" + " " + "$#$" + ratio + "$#$" + " " + "$#$" + formField.FullName.Replace('/', '-') + "$#$" + fieldType;
                    fields += "$#$" + (lowerLeftX * 2.08) * ratio + "$#$" + (lowerLeftY * 2.08) * ratio + "$#$" + (formField.Width * 2.08) * ratio + "$#$" + (formField.Height * 2.08) * ratio + "$#$" + formField.PageIndex + "$#$" + "image" + formField.PageIndex + ".png" + "$#$" + value + "$#$" + formField.DefaultAppearance.FontName + "$#$" + formField.DefaultAppearance.FontSize + "$#$" + " " + "$#$" + " " + "$#$" + isRequired + "$#$" + ratio + "$#$" + imValue + "$#$" + fieldcounter + "$#$" + fieldType;
                }
                int length = fields.Length;
                fieldcounter += 1;
                if (!licensed && fieldcounter == 5)
                {
                    break;
                }
            }



            return(fields);
        }
Example #31
0
 public static Aspose.Pdf.Facades.Form LoadPDFDoc()
 {
     Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();
     pdfForm.BindPdf(Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName + "\\SampleDoc\\PdfFormSample.pdf");
     return pdfForm;
 }
Example #32
0
        private static string CheckFields(Document doc, int pageCount, string filename, string fields, double ratio, bool licensed)
        {
            double marginLeft = doc.Pages[pageCount].PageInfo.Margin.Left;
            double marginTop = doc.Pages[pageCount].PageInfo.Margin.Top;
                       
            int fieldcounter = 0;
            
            Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form(doc);

            // Get values from all fields
            foreach (Field formField in doc.Form.Fields)
            {
                    

                    double lowerLeftY = (doc.Pages[pageCount].Rect.Height) - (formField.Rect.ToRect().Y + formField.Height);

                    double lowerLeftX = formField.Rect.ToRect().X;
                    var fieldType = formField.GetType().Name; //pdfForm.GetFieldType(formField.FullName);
                    var imValue = "";

                    if (fieldType.ToString() == "CheckboxField" || fieldType.ToString() == "ComboBoxField" || fieldType.ToString() == "RadioButtonOptionField" || fieldType.ToString() == "TextBoxField")
                    {
                        var value = formField.Value;

                        if (fieldType.ToString() == "TextBoxField")
                        {
                            fieldType = "Text";
                        }
                        if (fieldType.ToString() == "CheckboxField")
                        {
                            CheckboxField field = (CheckboxField)formField;
                            if (field.Parent != null) 
                            imValue = field.Parent.FullName;
                            fieldType = "CheckBox";
                            if (field.Checked)
                            {
                                value = "true";
                            }
                            else
                            {
                                value = "false";
                            }
                        }
                        if (fieldType.ToString() == "RadioButtonOptionField")
                        {
                            RadioButtonOptionField field = (RadioButtonOptionField)formField;
                            RadioButtonField rbf = (RadioButtonField)field.Parent;

                            fieldType = "Radio";
                            if (field.Parent != null)
                                imValue = field.Parent.FullName;
                            if ((rbf.Options[field.OptionName].Index == rbf.Selected))
                            {
                                value = "true";
                            }
                            else
                            {
                                value = "false";
                            }
                        }
                        if (fieldType.ToString() == "ComboBoxField")
                        {
                            ComboBoxField field = (ComboBoxField)formField;
                            string optValues = value;
                            fieldType = "ComboBox";
                            foreach (Option opt in field.Options)
                            {

                                optValues = optValues + "^^^" + opt.Value;

                            }
                            value = optValues;


                        }

                        bool isRequired = pdfForm.IsRequiredField(formField.FullName);
                        //fields += "$#$" + (lowerLeftX * 2.08) * ratio + "$#$" + (lowerLeftY * 2.08) * ratio + "$#$" + (formField.Width * 2.08) * ratio + "$#$" + (formField.Height * 2.08) * ratio + "$#$" + formField.PageIndex + "$#$" + "image" + formField.PageIndex + ".png" + "$#$" + value + "$#$" + formField.DefaultAppearance.FontName + "$#$" + formField.DefaultAppearance.FontSize + "$#$" + " " + "$#$" + " " + "$#$" + " " + "$#$" + ratio + "$#$" + " " + "$#$" + formField.FullName.Replace('/', '-') + "$#$" + fieldType;
                        fields += "$#$" + (lowerLeftX * 2.08) * ratio + "$#$" + (lowerLeftY * 2.08) * ratio + "$#$" + (formField.Width * 2.08) * ratio + "$#$" + (formField.Height * 2.08) * ratio + "$#$" + formField.PageIndex + "$#$" + "image" + formField.PageIndex + ".png" + "$#$" + value + "$#$" + formField.DefaultAppearance.FontName + "$#$" + formField.DefaultAppearance.FontSize + "$#$" + " " + "$#$" + " " + "$#$" + isRequired + "$#$" + ratio + "$#$" + imValue + "$#$" + fieldcounter + "$#$" + fieldType;
                    }
                    int length = fields.Length;
                    fieldcounter += 1;
                    if (!licensed && fieldcounter == 5)
                    {
                        break;
                    }
            }

            

            return fields;

        }