Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search Sign up Reseting focus

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

Bansnetsajak007/docx2pdf-converter

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Go to file

Folders and files

Last commit message Last commit date

Latest commit

History

View all files

Repository files navigation

Docx to PDF Converter

A 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.

Features

Installation

Install the package via npm:

npm i docx2pdf-converter

Usage

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')

converting entire directory of docs file into pdf file

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);

About

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.