Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active July 1, 2025 11:11
Show Gist options
  • Save GroupDocsGists/088275ce0cae6d62c6e44ca52aa90f8f to your computer and use it in GitHub Desktop.
Save GroupDocsGists/088275ce0cae6d62c6e44ca52aa90f8f to your computer and use it in GitHub Desktop.
How to merge PDF Files in Node.js

Merge PDF Files in Node.js

Looking for a quick way to merge PDF files? This Gist shows how to efficiently combine multiple PDF documents into a single file using Node.js.

πŸ“¦ Prerequisites

To get started, ensure that you have Node.js installed on your machine. Additionally, you'll need to install the GroupDocs.Merger package. You can download a free trial of GroupDocs.Merger and use a temporary license for unrestricted usage of our library. This library supports file types like PDF, DOCX, and XLSX, among others.

🧩 Key Capabilities

  • Effortlessly merge multiple PDF files into a single document for better organization.
  • Handle various file formats, not just PDFs, which includes Word, Excel, and images.
  • Simplify the automation of document management workflows in Node.js applications.
  • Save merged documents in a specified directory with custom naming options.
  • Easily integrate with your existing applications to enhance their functionality.

πŸ’» Code Examples

See the following example: mergePdf.js

βœ… How to Use in Node.js

  1. Install the GroupDocs.Merger package using npm: npm install @groupdocs.merger.
  2. Import the package in your Node.js application using require('@groupdocs.merger').
  3. Prepare the input file paths that you want to merge into a single PDF document.
  4. Create a merger instance and call the join function with the file paths.
  5. Save the output file in your designated output folder.

πŸ“Ž Related Resources

πŸ“œ Final Thoughts

By following these instructions, you can simplify how to merge PDF files and enhance your document management capabilities. Feel free to adapt this snippet for workflows in DOC, DOCX, PDF, and more. Check out our documentation or grab a trial to explore additional features and unleash the full potential of your file-format needs.

/*
* This example demonstrates how to merge multiple pdf files into single file.
*/
async function mergePdf(groupdocs, inputFilePath) {
const merger = new groupdocs.merger.Merger(inputFilePath)
const outputPath = `${groupdocs.outputFolder}/MergePdf.pdf`
console.log(`Merged to ${outputPath}`)
merger.join(inputFilePath)
return merger.save(outputPath)
}
module.exports = mergePdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment