Exemplo n.º 1
0
        public static void Run()
        {
            try
            {
                // ExStart:CopyOuterField
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

                // Open document
                FormEditor formEditor = new FormEditor();

                // Open the document and create a FormEditor object
                formEditor.BindPdf(dataDir + "CopyOuterField.pdf");

                // Copy a text field from one document to another one
                formEditor.CopyOuterField(dataDir + "input.pdf", "textfield", 1);

                // Close and save the output document
                formEditor.Save(dataDir + "CopyOuterField_out_.pdf");
                // ExEnd:CopyOuterField
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
            }
        }
Exemplo n.º 2
0
        public static void Run()
        {
            // ExStart:DecorateFields
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            // Open document
            FormEditor form = new FormEditor();

            // Open the document and create a FormEditor object
            form.BindPdf(dataDir + "DecorateFields.pdf");

            // Create a new facade object
            FormFieldFacade facade = new FormFieldFacade();

            // Assign the facade to form editor
            form.Facade = facade;

            // Set the backgroud color as red
            facade.BackgroundColor = System.Drawing.Color.Red;

            // Set the alignment as center
            facade.Alignment = FormFieldFacade.AlignCenter;

            // All text fields will be modified:
            form.DecorateField(FieldType.Text);

            // Close and validate the modification like this:
            form.Save(dataDir + "DecorateFields_out_.pdf");
            // ExEnd:DecorateFields
        }
        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()
        {
            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()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
            //open the document and create a FormEditor object
            FormEditor formEditor = new FormEditor(dataDir + "input_form.pdf", dataDir + "CopyOuterField_out.pdf");

            //copy a text field from one document to another one
            formEditor.CopyOuterField("textfieldform.pdf", "textfield", 1);
            //close and save the output document
            formEditor.Save();
        }
        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
        }
Exemplo n.º 7
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
            //create FormEditor object
            FormEditor formEditor = new FormEditor();

            //Open Document
            formEditor.BindPdf(dataDir + "CopyInnerField.pdf");
            //copy a field to another page
            formEditor.CopyInnerField("textfield", "newfieldname", 0);

            //close and save the output document
            formEditor.Save(dataDir + "CopyInnerField_out.pdf");
        }
        public static void Run()
        {
            // ExStart:SetSubmitButtonURL
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            FormEditor form = new FormEditor();

            // Open the document and create a FormEditor object
            form.BindPdf(dataDir + "input.pdf");
            // Set submit URL
            form.SetSubmitUrl("submitbutton", "http:// Www.aspose.com");
            // Save update document
            form.Save(dataDir + "SetSubmitButtonURL_out.pdf");
            // ExEnd:SetSubmitButtonURL
        }
Exemplo n.º 9
0
        public static void Run()
        {
            // ExStart:SetJSPushButton
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            FormEditor form = new FormEditor();

            // Open the document and create a FormEditor object
            form.BindPdf(dataDir + "input.pdf");
            // Set JavaScript
            form.SetFieldScript("pushbutton", "app.alert('Hello World!');");
            // Save update document
            form.Save(dataDir + "SetJSPushButton_out_.pdf");
            // ExEnd:SetJSPushButton
        }
Exemplo n.º 10
0
        public static void Run()
        {
            // ExStart:DeleteField
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            FormEditor formEditor = new FormEditor();
            // Open Document
            formEditor.BindPdf(dataDir + "DeleteFormField.pdf");

            // Delete field
            formEditor.RemoveField("textfield");
            // Save updated file
            formEditor.Save( dataDir + "DeleteFormField_out_.pdf");
            // ExEnd:DeleteField
        }
Exemplo n.º 11
0
        public static void Run()
        {
            // ExStart:DeleteListItem
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            FormEditor form = new FormEditor();

            // Open the document and create a FormEditor object
            form.BindPdf(dataDir + "AddListItem.pdf");
            // Delete list item
            form.DelListItem("listbox", "Item 2");
            // Save updated file
            form.Save(dataDir + "DeleteListItem_out.pdf");
            // ExEnd:DeleteListItem
        }
Exemplo n.º 12
0
        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
        }
Exemplo n.º 13
0
        public static void Run()
        {
            // ExStart:MoveField
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            FormEditor formEditor = new FormEditor();

            // Open Document
            formEditor.BindPdf(dataDir + "input.pdf");

            // Move field to new location
            formEditor.MoveField("textfield", 300, 300, 400, 400);
            // Save updated file
            formEditor.Save(dataDir + "MoveFormField_out_.pdf");
            // ExEnd:MoveField
        }
        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
        }
Exemplo n.º 15
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
        }
Exemplo n.º 16
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
            //create FormEditor object and open PDF file
            FormEditor form = new FormEditor(dataDir + "input_form.pdf", dataDir + "DecorateFields_out.pdf");
            //create a new facade object
            FormFieldFacade facade = new FormFieldFacade();

            //assign the facade to form editor
            form.Facade = facade;
            //set the backgroud color as red
            facade.BackgroundColor = System.Drawing.Color.Red;
            //set the alignment as center
            facade.Alignment = FormFieldFacade.AlignCenter;
            //all text fields will be modified:
            form.DecorateField(FieldType.Text);
            //close and validate the modification like this:
            form.Save();
        }
Exemplo n.º 17
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
        }
Exemplo n.º 18
0
        public static void Run()
        {
            // ExStart:DecorateParticularField
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            FormEditor form = new FormEditor();

            // Open the document and create a FormEditor object
            form.BindPdf(dataDir + "input.pdf");
            // Set field facade
            FormFieldFacade fieldFacade = new FormFieldFacade();

            form.Facade = fieldFacade;
            fieldFacade.BackgroundColor = System.Drawing.Color.Red;
            fieldFacade.FontSize        = 14;
            // Specify the form field which needs to be decorated
            form.DecorateField("textfield");
            // Save updated PDF form
            form.Save(dataDir + "DecorateParticularField_out.pdf");
            // ExEnd:DecorateParticularField
        }
Exemplo n.º 19
0
        public static void Run()
        {
            // ExStart:AddFormField
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            FormEditor formEditor = new FormEditor();

            // Open Document
            formEditor.BindPdf(dataDir + "AddFormField.pdf");

            // Add field
            formEditor.AddField(FieldType.Text, "textfield", 1, 100, 100, 200, 150);
            formEditor.AddField(FieldType.CheckBox, "checkboxfield", 1, 100, 200, 200, 250);
            formEditor.AddField(FieldType.ComboBox, "comboboxfield", 1, 100, 300, 200, 350);
            formEditor.AddField(FieldType.ListBox, "listboxfield", 1, 100, 400, 200, 450);
            formEditor.AddField(FieldType.MultiLineText, "multilinetextfield", 1, 100, 500, 200, 550);

            // Save updated file
            formEditor.Save(dataDir + "AddFormField_out_.pdf");
            // ExEnd:AddFormField
        }
Exemplo n.º 20
0
        public static void Run()
        {
            // ExStart:AddListItem
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

            FormEditor form = new FormEditor();

            // Open the document and create a FormEditor object
            form.BindPdf(dataDir + "AddListItem.pdf");
            // Add list field in PDF file
            form.AddField(FieldType.ListBox, "listbox", 1, 300, 200, 350, 225);
            // Add list items
            form.AddListItem("listbox", "Item 1");
            form.AddListItem("listbox", "Item 2");
            // Add multiple list items once
            string[] listItems = { "Item 3", "Item 4", "Item 5" };
            form.AddListItem("listbox", listItems);
            // Save updated file
            form.Save(dataDir + "AddListItem_out.pdf");
            // ExEnd:AddListItem
        }
Exemplo n.º 21
0
        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: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
        }