예제 #1
0
        /// <summary>
        /// Creates new signatures in the document and saves resultant document into &#39;Output&#39; folder
        /// </summary>
        /// <param name="request">Request. <see cref="CreateSignaturesRequest" /></param>
        /// <returns><see cref="SignResult"/></returns>
        public SignResult CreateSignatures(CreateSignaturesRequest request)
        {
            // verify the required parameter 'signSettings' is set
            if (request.signSettings == null)
            {
                throw new ApiException(400, "Missing required parameter 'signSettings' when calling CreateSignatures");
            }

            // create path and map variables
            var resourcePath = this.configuration.GetServerUrl() + "/signature/create";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            var postBody = SerializationHelper.Serialize(request.signSettings); // http body (model) parameter
            var response = this.apiInvoker.InvokeApi(
                resourcePath,
                "POST",
                postBody,
                null,
                null);

            if (response != null)
            {
                return((SignResult)SerializationHelper.Deserialize(response, typeof(SignResult)));
            }

            return(null);
        }
        public void SignStampPdf()
        {
            // Set request
            var testFile       = TestFiles.PdfStorage.FirstOrDefault();
            var fileInfo       = testFile.GetFileInfo();
            var signedFileName = $@"Output\PdfStampSigned.{testFile.Extension}";

            var options = new SignStampOptions();

            PopulateOptions(options);
            var signSettings = new SignSettings();

            signSettings.FileInfo    = fileInfo;
            signSettings.SaveOptions = new SaveOptions()
            {
                OutputFilePath = signedFileName
            };
            signSettings.Options = new List <SignOptions>()
            {
                options
            };
            var request = new CreateSignaturesRequest(signSettings);

            // Get and check result
            var response = SignatureApi.CreateSignatures(request);

            CheckResponse(response, testFile);

            //Download the signed file
            this.DownloadFile(signedFileName);
        }
        public void SignCollectionPdf()
        {
            // Set request
            var testFile       = TestFiles.PdfStorage.FirstOrDefault();
            var fileInfo       = testFile.GetFileInfo();
            var signedFileName = $@"Output\PdfCollectionSigned.{testFile.Extension}";

            var optionsBarcode = new SignBarcodeOptions();

            TestsSignBarcode.PopulateOptions(optionsBarcode);
            optionsBarcode.Top = 0;

            var optionsQrCode = new SignQRCodeOptions();

            TestsSignQrCode.PopulateOptions(optionsQrCode);
            optionsQrCode.Top = optionsBarcode.Height + 20;

            var optionsDigital = new SignDigitalOptions();

            TestsSignDigital.PopulateOptions(optionsDigital);
            optionsDigital.Top = optionsQrCode.Top + optionsQrCode.Height + 20;

            var optionsText = new SignTextOptions();

            TestsSignText.PopulateOptions(optionsText);
            optionsText.Top = optionsDigital.Top + optionsDigital.Height + 20;

            var optionsImage = new SignImageOptions();

            TestsSignImage.PopulateOptions(optionsImage);
            optionsImage.Top = optionsText.Top + optionsText.Height + 20;

            var optionsStamp = new SignStampOptions();

            TestsSignStamp.PopulateOptions(optionsStamp);
            optionsStamp.Top = optionsImage.Top + optionsImage.Height + 20;

            var signSettings = new SignSettings();

            signSettings.FileInfo    = fileInfo;
            signSettings.SaveOptions = new SaveOptions()
            {
                OutputFilePath = signedFileName
            };
            signSettings.Options = new List <SignOptions>()
            {
                optionsBarcode, optionsQrCode, optionsDigital, optionsText, optionsImage, optionsStamp
            };
            var request = new CreateSignaturesRequest(signSettings);

            // Get and check result
            var response = SignatureApi.CreateSignatures(request);

            CheckResponse(response, testFile);

            //Download the signed file
            this.DownloadFile(signedFileName);
        }