Files2Pdf is a Node.js package for converting PowerPoint (.ppt
, .pptx
) and Word (.doc
, .docx
) files to PDF. It processes all supported files within a folder and saves the converted PDFs to the specified output directory.
Install Files2Pdf globally to use it as a command-line tool:
npm install -g files2pdf
Or install it locally in your project:
npm install files2pdf
You can use Files2Pdf
directly from the command line.
files2pdf <input-folder> <output-folder>
-
<input-folder>
: Path to the folder containing the files to convert. -
<output-folder>
: Path to the folder where the converted PDFs will be saved.
files2pdf ./input ./output
This command converts all supported files in the ./input
folder to PDFs and saves them in the ./output
folder.
You can also use Files2Pdf
in your Node.js projects by importing the processFolder
function.
const { processFolder } = require('files2pdf');
const path = require('path');
const inputFolder = path.resolve('./input');
const outputFolder = path.resolve('./output');
processFolder(inputFolder, outputFolder)
.then(() => console.log('All files converted successfully!'))
.catch(err => console.error('Error converting files:', err));
- PowerPoint:
.ppt
,.pptx
- Word:
.doc
,.docx
- Converts multiple files in a folder to PDF.
- Supports both PowerPoint and Word file formats.
- Automatically skips unsupported file types.
- Creates the output folder if it doesn’t exist.
- Node.js (version 14 or higher recommended)
- LibreOffice installed on your system (required for the
libreoffice-convert
library to work).
If you encounter issues with the conversion:
- Ensure LibreOffice is installed and properly configured.
- Check file permissions for the input and output folders.
- Verify that the file formats are supported.