Skip to main content

Posts

Showing posts from February, 2024

PDF Merger Code in JavaScript

Hello, The following code uses the pdf-merger-js node.js library. You can read more about it here . 1. Create a new folder at your desired location (Folder Name - Merge PDF). 2. Inside this folder, create a new JavaScript file (File Name - mergerCode.js). 3. Open a terminal inside the newly created folder and execute the following command     npm init 4. Few questions would be asked related to creation of new package. If you don't want to modify anything, follow the prompts. A new package.json file will be created. 5. Edit this package.json file and add "type":"module" 6. Now execute the following command in the terminal     npm install --save pdf-merger-js 7. Add the code given below in the mergerCode file. 8. Save the file and execute  node <fileName.js> Source Code - You can add as many PDF files as you want.  In the parenthesis mention the path/filename of the PDF. import PDFMerger from "pdf-merger-js" ; var merger = new PDFMerger ();