GroupDocsGists
10/24/2017 - 1:27 PM

addingsignature.cs

 var settings = new SignatureSignSettings
      {
          DocumentName = "sample.pdf",
          DocumentContent = inputDocument
      };

      // set stamp image
      var converter = new ImageConverter();
      settings.StampImage = (byte[])converter.ConvertTo(Resource.Stamp, typeof(byte[]));

      // setup document template in summary page from resource
      settings.SummaryPage.DocumentTemplate = GenerateStreamFromString(Resource.DocumentTemplate);

      // setup recipient template in summary page from resource
      settings.SummaryPage.RecipientTemplate = GenerateStreamFromString(Resource.RecipientTemplate);

      // change date format in summary page
      settings.SummaryPage.DateFormat = "yyyy.MM.dd hh:mm:ss";

      // setup John Doe recipient
      var johnDoe = new SignatureSignRecipientSettings
      {
           Name = "John Doe",
           Email = "john@doe.com",
           SignedDateTime = DateTime.Now,
           SignerIpAddress = "127.0.0.1"
      };

      // add signature field with location
      johnDoe.Fields.Add(new SignatureSignFieldSettings
      {
             Name = "Signature1",
             FieldType = SignatureFieldType.Signature,
             Data =
                   Encoding.UTF8.GetBytes(
                       "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewbox=\"0 0 228 82\" preserveaspectratio=\"none\"><text font-family=\"Tangerine\" font-size=\"60px\" fill=\"#0036D9\" y=\"50%\" x=\"10%\" dy=\"0.3em\">John Doe</text><defs><link href=\"http://fonts.googleapis.com/css?family=Tangerine\" type=\"text/css\" rel=\"stylesheet\" xmlns=\"http://www.w3.org/1999/xhtml\"><style type=\"text/css\">@import url(http://fonts.googleapis.com/css?family=Tangerine)</style></defs></svg>"),
             Locations = new List<SignatureSignFieldLocationSettings>
             {
                   new SignatureSignFieldLocationSettings
                   {
                       Page = 1,
                       LocationWidth = (decimal) 421.44,
                       LocationHeight = (decimal) 120.4,
                       LocationX = (decimal) 0.591397849462366,
                       LocationY = (decimal) 0.790456100342075
                   }
             }
        });

          // add text field with location
          johnDoe.Fields.Add(new SignatureSignFieldSettings
                {
                    Name = "Text field1",
                    FieldType = SignatureFieldType.SingleLine,
                    Data = Encoding.UTF8.GetBytes("John Doe simple text"),
                    Locations = new List<SignatureSignFieldLocationSettings>
                    {
                        new SignatureSignFieldLocationSettings
                        {
                            Page = 1,
                            LocationWidth = (decimal) 676.975,
                            LocationHeight = (decimal) 45.826,
                            LocationX = (decimal) 0.362903225806452,
                            LocationY = (decimal) 0.229142911440517
                        }
                    }
                });

          // add John Doe to document recipients
          settings.Recipients.Add(johnDoe);