示例#1
0
        public void TestPostSignDocument()
        {
            PdfApi target = new PdfApi(APIKEY, APPSID, BASEPATH);
            StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH);

            string name = "signature.pdf";
            string storage = null;
            string folder = null;

            Com.Aspose.PDF.Model.Field field = new Com.Aspose.PDF.Model.Field();

            Com.Aspose.PDF.Model.Link link = new Com.Aspose.PDF.Model.Link();
            link.Href = "http://api.aspose.com/v1.1/pdf/ABFillablewfields.pdf/fields/NewField";
            link.Rel = "self";
            link.Title = "NewField";
            link.Type = "0";

            Com.Aspose.PDF.Model.Rectangle rect = new Com.Aspose.PDF.Model.Rectangle();
            rect.X = 100;
            rect.Y = 100;
            rect.Height = 100;
            rect.Width = 200;

            field.Name = "signature";
            field.Values = new System.Collections.Generic.List<string> { "NewFieldValue" };
            field.Rect = rect;
            field.SelectedItems = new System.Collections.Generic.List<int?> { 1 };
            field.Type = 0;
            field.Links = new System.Collections.Generic.List<Com.Aspose.PDF.Model.Link> { link };

            target.PutUpdateField(name, storage, folder, field.Name, field);

            Com.Aspose.PDF.Model.Signature body = new Com.Aspose.PDF.Model.Signature();
            body.Authority = "Imran Anwar";
            body.Contact = "*****@*****.**";
            body.Date = "1-1-2016";
            body.FormFieldName = field.Name;
            body.Location = "Faisalabad";
            body.Password = "******";
            body.Rectangle = rect;
            body.SignaturePath = "pkc7-sample.pfx";
            body.SignatureType = "PKCS7";
            body.Visible = true;

            storageApi.PutCreate(name, null, null, System.IO.File.ReadAllBytes("\\temp\\pdf\\resources\\" + name));

            Com.Aspose.PDF.Model.FieldResponse fieldResponse = target.PutUpdateField(name, storage, folder, field.Name, field);
            if (fieldResponse != null)
            {
                Console.WriteLine("Field added, Done!");
            }
            storageApi.PutCreate(body.SignaturePath, null, null, System.IO.File.ReadAllBytes("\\temp\\pdf\\resources\\" + body.SignaturePath));

            target.PutUpdateField(name, storage, folder, "signature", field);

            Com.Aspose.PDF.Model.SaaSposeResponse actual;
            actual = target.PostSignDocument(name, storage, folder, body);

            Assert.AreEqual("200", actual.Code);
            Assert.IsInstanceOfType(new Com.Aspose.PDF.Model.SaaSposeResponse(), actual.GetType());
        }