DEV Community

udiko
udiko

Posted on

 

docx to pdf with Node.js

Most of the npms didnt works for me but this one do the job:

npm i convert-multiple-files

convert.ts:

import { convertWordFiles } from 'convert-multiple-files';

const docToPdf = async (filePath: string, outputDir: string): Promise<string> => await convertWordFiles(filePath, 'pdf', outputDir);

export {
    docToPdf
};

Enter fullscreen mode Exit fullscreen mode

const outputFile = await docToPdf('file.docx', './outFolder');

Top comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.