Example #1
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     = "SampleProtectedBlankWordDocument.docx";
            String            destFileName = fileName;
            String            storage      = null;
            String            folder       = null;
            ProtectionRequest body         = new ProtectionRequest();

            body.Password = "******";

            try
            {
                // Upload the file
                storageApi.PutCreate(fileName, "", storage, System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName));
                // Invoke Aspose.Words Cloud SDK API to remove the protection
                ProtectionDataResponse apiResponse = wordsApi.DeleteUnprotectDocument(fileName, destFileName, storage, folder, body);

                if (apiResponse != null && apiResponse.Status.Equals("OK"))
                {
                    Console.WriteLine("Document has been unprotected successfully");
                    Console.ReadKey();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
            }
            // ExEnd:1
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProtectDocumentOnlineRequest"/> class.
 /// </summary>
 /// <param name="document">The document.</param>
 /// <param name="protectionRequest">Protection request.</param>
 /// <param name="loadEncoding">Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.</param>
 /// <param name="password">Password for opening an encrypted document.</param>
 /// <param name="destFileName">Result path of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.</param>
 public ProtectDocumentOnlineRequest(System.IO.Stream document, ProtectionRequest protectionRequest, string loadEncoding = null, string password = null, string destFileName = null)
 {
     this.Document          = document;
     this.ProtectionRequest = protectionRequest;
     this.LoadEncoding      = loadEncoding;
     this.Password          = password;
     this.DestFileName      = destFileName;
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PostChangeDocumentProtectionRequest"/> class.
 /// </summary>
 /// <param name="name">The document name.</param>
 /// <param name="protectionRequest">with protection settings.            </param>
 /// <param name="folder">Original document folder.</param>
 /// <param name="storage">File storage, which have to be used.</param>
 /// <param name="loadEncoding">Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.</param>
 /// <param name="password">Password for opening an encrypted document.</param>
 /// <param name="destFileName">Result name of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.</param>
 public PostChangeDocumentProtectionRequest(string name, ProtectionRequest protectionRequest, string folder = null, string storage = null, string loadEncoding = null, string password = null, string destFileName = null)
 {
     this.Name = name;
     this.ProtectionRequest = protectionRequest;
     this.Folder            = folder;
     this.Storage           = storage;
     this.LoadEncoding      = loadEncoding;
     this.Password          = password;
     this.DestFileName      = destFileName;
 }
Example #4
0
        public void TestPostChangeDocumentProtection()
        {
            var localName  = "test_multi_pages.docx";
            var remoteName = "TestPostChangeDocumentProtection.docx";
            var fullName   = Path.Combine(this.dataFolder, remoteName);
            var body       = new ProtectionRequest {
                NewPassword = string.Empty
            };

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

            var request = new PostChangeDocumentProtectionRequest(remoteName, body, this.dataFolder);
            var actual  = this.WordsApi.PostChangeDocumentProtection(request);

            Assert.AreEqual(200, actual.Code);
        }
Example #5
0
        public void TestDeleteUnprotectDocument()
        {
            var localName  = "SampleProtectedBlankWordDocument.docx";
            var remoteName = "TestDeleteUnprotectDocument.docx";
            var fullName   = Path.Combine(this.dataFolder, remoteName);
            var body       = new ProtectionRequest {
                Password = "******"
            };

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

            var request = new DeleteUnprotectDocumentRequest(remoteName, body, this.dataFolder);
            var actual  = this.WordsApi.DeleteUnprotectDocument(request);

            Assert.AreEqual(200, actual.Code);
        }