public static void AddSignatureFields()
        {
            // ExStart:AddSignatureFields
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
            Document doc = new Document(dataDir + "inFile.pdf");
            // Create FormEditor object
            FormEditor editor = new FormEditor(doc);
            // Add signature fields
            editor.AddField(FieldType.Signature, "Signature from Alice", 1, 10, 10, 110, 110);
            editor.AddField(FieldType.Signature, "Signature from John", 1, 120, 150, 220, 250);
            editor.AddField(FieldType.Signature, "Signature from Smith", 1, 300, 200, 400, 300);
            // Save the form
            editor.Save(dataDir + "AddSignatureFields_1_out.pdf");

            Document doc2 = new Document(dataDir + "inFile2.pdf");
            // Add signature to any of the signature fields
            PdfFileSignature pdfSign = new PdfFileSignature(doc2);
            pdfSign.Sign("Signature from John", "Signature Reason", "John", "Kharkov", new PKCS1("inFile1.pdf", "password"));
            // Each time new signature is added you must save the document
            pdfSign.Save(dataDir + "AddSignatureFields_2_out.pdf");

            Document doc3 = new Document(dataDir + "FilledForm.pdf");
            // Add second signature
            PdfFileSignature pdfSign2 = new PdfFileSignature(doc3);
            pdfSign2.Sign("Signature from Alice", "Signature Reason", "Alice", "Odessa", new PKCS1(dataDir + "FilledForm - 2.pfx", "password"));
            // Each time new signature is added you must save the document
            pdfSign2.Save(dataDir + "AddSignatureFields_3_out.pdf");
            // ExEnd:AddSignatureFields
        }
        public static void AddSignatureFields()
        {
            // ExStart:AddSignatureFields
            // The path to the documents directory.
            string   dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
            Document doc     = new Document(dataDir + "inFile.pdf");
            // Create FormEditor object
            FormEditor editor = new FormEditor(doc);

            // Add signature fields
            editor.AddField(FieldType.Signature, "Signature from Alice", 1, 10, 10, 110, 110);
            editor.AddField(FieldType.Signature, "Signature from John", 1, 120, 150, 220, 250);
            editor.AddField(FieldType.Signature, "Signature from Smith", 1, 300, 200, 400, 300);
            // Save the form
            editor.Save(dataDir + "AddSignatureFields_1_out.pdf");

            Document doc2 = new Document(dataDir + "inFile2.pdf");
            // Add signature to any of the signature fields
            PdfFileSignature pdfSign = new PdfFileSignature(doc2);

            pdfSign.Sign("Signature from John", "Signature Reason", "John", "Kharkov", new PKCS1("inFile1.pdf", "password"));
            // Each time new signature is added you must save the document
            pdfSign.Save(dataDir + "AddSignatureFields_2_out.pdf");

            Document doc3 = new Document(dataDir + "FilledForm.pdf");
            // Add second signature
            PdfFileSignature pdfSign2 = new PdfFileSignature(doc3);

            pdfSign2.Sign("Signature from Alice", "Signature Reason", "Alice", "Odessa", new PKCS1(dataDir + "FilledForm - 2.pfx", "password"));
            // Each time new signature is added you must save the document
            pdfSign2.Save(dataDir + "AddSignatureFields_3_out.pdf");
            // ExEnd:AddSignatureFields
        }
        public static void Run()
        {
            // ExStart:FormEditorFeatures
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            Document doc = new Document(dataDir + "inFile.pdf");
            // Create instance of FormEditor
            FormEditor editor = new FormEditor(doc);

            // Add field in the PDF file
            editor.AddField(FieldType.Text, "field1", 1, 300, 500, 350, 525);

            // Add List field in PDF file
            editor.AddField(FieldType.ListBox, "field2", 1, 300, 200, 350, 225);

            // Add list items
            editor.AddListItem("field2", "item 1");
            editor.AddListItem("field2", "item 2");

            // Add submit button
            editor.AddSubmitBtn("submitbutton", 1, "Submit Form", "http:// Testwebsite.com/testpage", 200, 200, 250, 225);

            // Delete list item
            editor.DelListItem("field2", "item 1");

            // Move field to new position
            editor.MoveField("field1", 10, 10, 50, 50);

            // Remove existing field from the PDF
            editor.RemoveField("field1");

            // Rename an existing field
            editor.RenameField("field1", "newfieldname");

            // Reset all visual attributes to empty value
            editor.ResetFacade();

            // Set the alignment style of a text field
            editor.SetFieldAlignment("field1", FormFieldFacade.AlignLeft);

            // Set appearance of the field
            editor.SetFieldAppearance("field1", AnnotationFlags.NoRotate);

            // Set field attributes i.e. ReadOnly, Required
            editor.SetFieldAttribute("field1", PropertyFlag.ReadOnly);

            // Set field limit
            editor.SetFieldLimit("field1", 25);

            // Save modifications in the output file
            editor.Save(dataDir + "FormEditorFeatures2_out.pdf");
            // ExEnd:FormEditorFeatures
        }
        public static void Run()
        {
            // ExStart:FormEditorFeatures
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            Document doc = new Document(dataDir + "inFile.pdf");
            // Create instance of FormEditor
            FormEditor editor = new FormEditor(doc);

            // Add field in the PDF file
            editor.AddField(FieldType.Text, "field1", 1, 300, 500, 350, 525);

            // Add List field in PDF file
            editor.AddField(FieldType.ListBox, "field2", 1, 300, 200, 350, 225);

            // Add list items
            editor.AddListItem("field2", "item 1");
            editor.AddListItem("field2", "item 2");

            // Add submit button
            editor.AddSubmitBtn("submitbutton", 1, "Submit Form", "http:// Testwebsite.com/testpage", 200, 200, 250, 225);

            // Delete list item
            editor.DelListItem("field2", "item 1");

            // Move field to new position
            editor.MoveField("field1", 10, 10, 50, 50);

            // Remove existing field from the PDF
            editor.RemoveField("field1");

            // Rename an existing field
            editor.RenameField("field1", "newfieldname");

            // Reset all visual attributes to empty value
            editor.ResetFacade();

            // Set the alignment style of a text field
            editor.SetFieldAlignment("field1", FormFieldFacade.AlignLeft);

            // Set appearance of the field
            editor.SetFieldAppearance("field1", AnnotationFlags.NoRotate);

            // Set field attributes i.e. ReadOnly, Required
            editor.SetFieldAttribute("field1", PropertyFlag.ReadOnly);

            // Set field limit
            editor.SetFieldLimit("field1", 25);

            // Save modifications in the output file
            editor.Save(dataDir + "FormEditorFeatures2_out.pdf");
            // ExEnd:FormEditorFeatures                      
        }
        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 Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //open document
            FormEditor formEditor = new FormEditor();
            //Open Document
            formEditor.BindPdf(dataDir+ "input.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+ "output.pdf");
        }
        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
        }
        public static void Run()
        {
            try
            {
                // ExStart:HorizontallyAndVerticallyRadioButtons
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdf_Forms();

                // Load the previously saved document
                FormEditor formEditor = new FormEditor();
                formEditor.BindPdf(dataDir + "input.pdf");
                // RadioGap is distance between two radio button options.
                formEditor.RadioGap = 4;
                // Add horizontal radio button
                formEditor.RadioHoriz = true;
                // RadioButtonItemSize if size of radio button item.
                formEditor.RadioButtonItemSize = 20;
                formEditor.Facade.BorderWidth  = 1;
                formEditor.Facade.BorderColor  = System.Drawing.Color.Black;
                formEditor.Items = new string[] { "First", "Second", "Third" };
                formEditor.AddField(FieldType.Radio, "NewField1", 1, 40, 600, 120, 620);

                // Add other radio button situated vertically
                formEditor.RadioHoriz = false;
                formEditor.Items      = new string[] { "First", "Second", "Third" };
                formEditor.AddField(FieldType.Radio, "NewField2", 1, 40, 500, 60, 550);


                dataDir = dataDir + "HorizontallyAndVerticallyRadioButtons_out_.pdf";
                // Save the PDF document
                formEditor.Save(dataDir);
                // ExEnd:HorizontallyAndVerticallyRadioButtons
                Console.WriteLine("\nHorizontally and vertically laid out radio buttons successfully.\nFile saved at " + dataDir);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static void Run()
        {
            try
            {
                // ExStart:HorizontallyAndVerticallyRadioButtons
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdf_Forms();

                // Load the previously saved document
                FormEditor formEditor = new FormEditor();
                formEditor.BindPdf(dataDir + "input.pdf");
                // RadioGap is distance between two radio button options. 
                formEditor.RadioGap = 4;
                // Add horizontal radio button
                formEditor.RadioHoriz = true;
                // RadioButtonItemSize if size of radio button item.
                formEditor.RadioButtonItemSize = 20;
                formEditor.Facade.BorderWidth = 1;
                formEditor.Facade.BorderColor = System.Drawing.Color.Black;
                formEditor.Items = new string[] { "First", "Second", "Third" };
                formEditor.AddField(FieldType.Radio, "NewField1", 1, 40, 600, 120, 620);

                // Add other radio button situated vertically
                formEditor.RadioHoriz = false;
                formEditor.Items = new string[] { "First", "Second", "Third" };
                formEditor.AddField(FieldType.Radio, "NewField2", 1, 40, 500, 60, 550);


                dataDir = dataDir + "HorizontallyAndVerticallyRadioButtons_out.pdf";
                // Save the PDF document
                formEditor.Save(dataDir);
                // ExEnd:HorizontallyAndVerticallyRadioButtons
                Console.WriteLine("\nHorizontally and vertically laid out radio buttons successfully.\nFile saved at " + dataDir);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #11
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
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

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

            //Open Document
            formEditor.BindPdf(dataDir + "input.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 + "output.pdf");
        }
 public static void Main()
 {
     // The path to the documents directory.
     string dataDir = Path.GetFullPath("../../../Data/");
     //create instance of FormEditor
     FormEditor formEditor = new FormEditor();
     //Open Document
     formEditor.BindPdf(dataDir+ "input.pdf");
     //add list field in PDF file
     formEditor.AddField(FieldType.ListBox, "listbox", 1, 300, 200, 350, 225);
     //add list items
     formEditor.AddListItem("listbox", "Item 1");
     formEditor.AddListItem("listbox", "Item 2");
     //add multiple list items once
     string[] listItems = { "Item 3", "Item 4", "Item 5" };
     formEditor.AddListItem("listbox", listItems);
     //save updated file
     formEditor.Save(dataDir+ "output.pdf");
 }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //create instance of FormEditor
            FormEditor formEditor = new FormEditor();

            //Open Document
            formEditor.BindPdf(dataDir + "input.pdf");
            //add list field in PDF file
            formEditor.AddField(FieldType.ListBox, "listbox", 1, 300, 200, 350, 225);
            //add list items
            formEditor.AddListItem("listbox", "Item 1");
            formEditor.AddListItem("listbox", "Item 2");
            //add multiple list items once
            string[] listItems = { "Item 3", "Item 4", "Item 5" };
            formEditor.AddListItem("listbox", listItems);
            //save updated file
            formEditor.Save(dataDir + "output.pdf");
        }
        public static void Run()
        {
            // ExStart:ChangingFieldAppearance
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            Document doc = new Document(dataDir + "FilledForm.pdf");
            // Open the document and create a Form object
            FormEditor formEditor = new FormEditor(doc);
            // Add a text field
            formEditor.AddField(FieldType.Text, "text1", 1, 200, 550, 300, 575);
           
            // Set field attribute - PropertyFlag enumeration contains 4 options
            formEditor.SetFieldAttribute("text1", PropertyFlag.Required);
            // Set field limit - this field will take maximum 20 characters as input
            formEditor.SetFieldLimit("text1", 20);

            // Close the document
            formEditor.Save(dataDir + "ChangingFieldAppearance_out.pdf");
            // ExEnd:ChangingFieldAppearance                      
        }
        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
        }        
        public static void Run()
        {
            // ExStart:ChangingFieldAppearance
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

            Document doc = new Document(dataDir + "FilledForm.pdf");
            // Open the document and create a Form object
            FormEditor formEditor = new FormEditor(doc);

            // Add a text field
            formEditor.AddField(FieldType.Text, "text1", 1, 200, 550, 300, 575);

            // Set field attribute - PropertyFlag enumeration contains 4 options
            formEditor.SetFieldAttribute("text1", PropertyFlag.Required);
            // Set field limit - this field will take maximum 20 characters as input
            formEditor.SetFieldLimit("text1", 20);

            // Close the document
            formEditor.Save(dataDir + "ChangingFieldAppearance_out.pdf");
            // ExEnd:ChangingFieldAppearance
        }
        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
        }