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 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
 }       
Exemplo n.º 4
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
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
0
        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
        }
Exemplo n.º 8
0
        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: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.º 11
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.º 12
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: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: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
        }        
Exemplo n.º 17
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
        }