예제 #1
0
        public void CustomStorageTest(string inputFileName)
        {
            SignatureConfig config     = new SignatureConfig();
            string          rootPath   = Path.GetFullPath(@"..\..\");
            string          imagesPath = Path.Combine(rootPath, @"Images");

            string fileName;

            SaveOptions       saveOptions = new SaveOptions(OutputType.String);
            IInputDataHandler customInputStorageProvider = new SampleAzureInputDataHandler(DevStorageEmulatorUrl,
                                                                                           DevStorageEmulatorAccountName, DevStorageEmulatorAccountKey, "testbucket");
            IOutputDataHandler customOutputStorageProvider = new SampleAzureOutputDataHandler(
                DevStorageEmulatorUrl, DevStorageEmulatorAccountName, DevStorageEmulatorAccountKey, "tempbucket");
            SignatureHandler handlerWithCustomStorage = new SignatureHandler(config, customInputStorageProvider, customOutputStorageProvider);

            LicenseSetter.SetSignatureLicense(handlerWithCustomStorage);

            using (Stream imageStream = File.OpenRead(Path.Combine(imagesPath, "Autograph_of_Benjamin_Franklin.png")))
            {
                PdfSignImageOptions options = new PdfSignImageOptions(imageStream);
                options.DocumentPageNumber = 1;
                options.Top    = 500;
                options.Width  = 200;
                options.Height = 100;
                fileName       = handlerWithCustomStorage.Sign <string>(inputFileName, options, saveOptions);
            }
            Console.WriteLine("Document signed successfully. The output filename: {0}", fileName);
        }
예제 #2
0
        public void UploadTestFile(string inputFileName)
        {
            string rootPath    = Path.GetFullPath(@"..\..\");
            string storagePath = Path.Combine(rootPath, @"Storage");

            IOutputDataHandler customOutputStorageProvider = new SampleAzureOutputDataHandler(
                DevStorageEmulatorUrl, DevStorageEmulatorAccountName, DevStorageEmulatorAccountKey, "testbucket");

            using (Stream blobStream = customOutputStorageProvider.CreateFile(inputFileName))
            {
                byte[] fileBytes = File.ReadAllBytes(Path.Combine(storagePath, inputFileName));
                using (MemoryStream inputStream = new MemoryStream(fileBytes))
                {
                    inputStream.CopyTo(blobStream);
                }
            }
        }