Last active
July 28, 2023 06:42
Add Password to Word Document | Password Protect Word Files using Node.js| DOC DOCX Password Protector REST API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Construct FileApi | |
var fileApi = new groupdocs_merger_cloud.FileApi(configuration); | |
// Create download file request | |
let request = new groupdocs_merger_cloud.DownloadFileRequest("add-password.docx", myStorage); | |
// Download file | |
let response = await fileApi.downloadFile(request); | |
// Save file in your working directory | |
fs.writeFile("C:\\Files\\Annotation\\output.pdf", response, "binary", function (err) { }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code example demonstrates how to add your client Id and Secret in the code. | |
global.clientId = "659fe7da-715b-4744-a0f7-cf469a392b73"; | |
global.clientSecret = "b377c36cfa28fa69960ebac6b6e36421"; | |
global.myStorage = ""; | |
const configuration = new groupdocs_merger_cloud.Configuration(clientId, clientSecret); | |
configuration.apiBaseUrl = "https://api.groupdocs.cloud"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/groupdocs-merger-cloud/groupdocs-merger-cloud-node-samples | |
global.appSid = "XXXX-XXXX-XXXX-XXXX"; | |
global.appKey = "XXXXXXXXXXXXXXXX"; | |
global.securityApi = merger_cloud.SecurityApi.fromKeys(appSid, appKey); | |
let options = new merger_cloud.Options(); | |
options.fileInfo = new merger_cloud.FileInfo(); | |
options.fileInfo.filePath = "WordProcessing/one-page.docx"; | |
options.fileInfo.password = "Pass123"; | |
options.outputPath = "Output/add-password.docx"; | |
let result = await securityApi.addPassword(new merger_cloud.AddPasswordRequest(options)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize api instance | |
var fileApi = new groupdocs_merger_cloud.FileApi(configuration); | |
// Open file in IOStream from local/disc. | |
var resourcesFolder = 'C:\\Files\\Annotation\\sample.pdf'; | |
// Read the file | |
fs.readFile(resourcesFolder, (err, fileStream) => { | |
// Upload file request | |
var request = new groupdocs_merger_cloud.UploadFileRequest("one-page.docx", fileStream, myStorage); | |
// Upload file | |
fileApi.uploadFile(request); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment