1.1.0 • Published 11 months ago
files2pdf v1.1.0
Files2Pdf
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.
Installation
Install Files2Pdf globally to use it as a command-line tool:
npm install -g files2pdfOr install it locally in your project:
npm install files2pdfUsage
Command Line Interface (CLI)
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.
Example
files2pdf ./input ./outputThis command converts all supported files in the ./input folder to PDFs and saves them in the ./output folder.
Programmatic Usage
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));Supported File Types
- PowerPoint:
.ppt,.pptx - Word:
.doc,.docx
Features
- 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.
Requirements
- Node.js (version 14 or higher recommended)
- LibreOffice installed on your system (required for the
libreoffice-convertlibrary to work).
Troubleshooting
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.