Exemplo n.º 1
0
        public void TestGetFormField()
        {
            var localName      = "FormFilled.docx";
            var remoteName     = "TestGetFormField.docx";
            var fullName       = Path.Combine(this.dataFolder, remoteName);
            int formfieldIndex = 0;

            this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir(this.fieldFolder) + localName));

            var request = new GetFormFieldRequest(remoteName, formfieldIndex, this.dataFolder, nodePath: "sections/0");
            FormFieldResponse actual = this.WordsApi.GetFormField(request);

            Assert.AreEqual(200, actual.Code);
        }
Exemplo n.º 2
0
        public static void Run()
        {
            // ExStart:1
            WordsApi   wordsApi   = new WordsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);
            StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);

            string fileName         = "test_multi_pages.docx";
            int    sectionIndex     = 0;
            int    paragraphIndex   = 0;
            string insertBeforeNode = null;
            string destFileName     = "test.docx";
            string storage          = null;
            string folder           = null;

            FormField body = new FormField();
            Link      lnk  = new Link();

            lnk.Href = "";

            body.Name             = "FullName";
            body.Enabled          = true;
            body.CalculateOnExit  = true;
            body.StatusText       = "";
            body.link             = lnk;
            body.TextInputType    = "Regular";
            body.TextInputDefault = "";
            body.TextInputFormat  = "UPPERCASE";

            try
            {
                // Upload the file
                storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName));
                // Invoke Aspose.Words Cloud SDK API to add form fileds
                FormFieldResponse apiResponse = wordsApi.PutFormField(fileName, sectionIndex, paragraphIndex, insertBeforeNode, destFileName, storage, folder, body);

                if (apiResponse != null && apiResponse.Status.Equals("OK"))
                {
                    Console.WriteLine("Form field has been added successfully");
                    Console.ReadKey();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
            }
            // ExEnd:1
        }
Exemplo n.º 3
0
        public void TestPostFormField()
        {
            var localName      = "FormFilled.docx";
            var remoteName     = "TestPostFormField.docx";
            var fullName       = Path.Combine(this.dataFolder, remoteName);
            var formfieldIndex = 0;
            var destFileName   = Path.Combine(BaseTestOutPath, remoteName);

            FormFieldTextInput body = new FormFieldTextInput
            {
                Name             = "FullName",
                Enabled          = true,
                CalculateOnExit  = true,
                StatusText       = string.Empty,
                TextInputType    = FormFieldTextInput.TextInputTypeEnum.Regular,
                TextInputDefault = string.Empty
            };

            this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir(this.fieldFolder) + localName));

            var request = new PostFormFieldRequest(remoteName, body, formfieldIndex, this.dataFolder, nodePath: "sections/0", destFileName: destFileName);

            FormFieldResponse actual = this.WordsApi.PostFormField(request);

            Assert.AreEqual(200, actual.Code);
            Assert.AreEqual("FullName", actual.FormField.Name);
            Assert.AreEqual(true, actual.FormField.Enabled);

            var formFieldTextInput = actual.FormField as FormFieldTextInput;

            Assert.IsTrue(formFieldTextInput != null,
                          "Incorrect type of formfield: {0} instead of {1}",
                          actual.FormField.GetType(),
                          typeof(FormFieldTextInput));
            Assert.AreEqual(FormFieldTextInput.TextInputTypeEnum.Regular, formFieldTextInput.TextInputType);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateFormFieldOnlineResponse"/> class.
 /// </summary>
 /// <param name="model">The response model.</param>
 /// <param name="document">The document after modification.</param>
 public UpdateFormFieldOnlineResponse(FormFieldResponse model, System.IO.Stream document)
 {
     this.Model    = model;
     this.Document = document;
 }