You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A cross-platform npm package for converting `.docx` files to PDF. Supports Windows, macOS, and Linux. Includes functionality for converting PDFs back to DOCX on Windows. Simple and versatile file conversion.
Notifications You must be signed in to change notification settings
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Go to fileA lightweight npm package designed to convert Word documents (docx) to PDF format. While similar tools exist in Python, I found a gap in the JavaScript ecosystem and decided to fill it by creating this simple and efficient solution.
Install the package via npm:
npm i docx2pdf-converter
This line of code simply converts single docx file into pdf file
const topdf = require('docx2pdf-converter') const inputPath = './report.docx'; topdf.convert(inputPath,'output.pdf')
This line of code converts entire directory of docx file into another directory of pdf file
const fs = require('fs'); const path = require('path'); const convert, resolvePaths > = require('docx2pdf-converter'); function convertDirectory(inputDir, outputDir) const files = fs.readdirSync(inputDir); files.forEach((file) => if (file.endsWith('.docx')) const inputPath = path.join(inputDir, file); const output > = resolvePaths(inputPath, outputDir); convert(inputPath, output); console.log(`Converted: $file>`); > >); > /* assume the both directories input and output are in same folder if they dont exist the you can give absolute path to that folder */ const inputDirectory = './inputdir'; const outputDirectory = './outputdir'; convertDirectory(inputDirectory, outputDirectory);
A cross-platform npm package for converting `.docx` files to PDF. Supports Windows, macOS, and Linux. Includes functionality for converting PDFs back to DOCX on Windows. Simple and versatile file conversion.