Created
September 29, 2023 21:21
Combine Text Files using a TXT File Merger
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
// Include the groupdocs-merger-cloud module in your app. | |
const merger_cloud = require("groupdocs-merger-cloud"); | |
const clientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; | |
const clientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"; | |
// Initialize the instance of the DocumentApi with the API credentials. | |
const documentApi = merger_cloud.DocumentApi.fromKeys(clientId, clientSecret); | |
// Instantiate an object of the JoinItem class. | |
let item1 = new merger_cloud.JoinItem(); | |
// Create an object of the FileInfo class. | |
item1.fileInfo = new merger_cloud.FileInfo(); | |
// Set the file path of the source Text file. | |
item1.fileInfo.filePath = "first.txt"; | |
let item2 = new merger_cloud.JoinItem(); | |
item2.fileInfo = new merger_cloud.FileInfo(); | |
item2.fileInfo.filePath = "second.txt"; | |
// Create an object of the JoinOptions class. | |
let options = new merger_cloud.JoinOptions(); | |
// Call the JoinItems property to assign the source document array. | |
options.joinItems = [item1, item2]; | |
// Set the output path for generated merged document. | |
options.outputPath = "Output/joined.txt"; | |
// Initialize an instance of the JoinRequest class and pass it into the join method. | |
documentApi.join(new merger_cloud.JoinRequest(options)).then(()=>console.log("Done successfully")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment