How to Convert PPT or PDF Files to PNG Images Using Node.js

Check out this article to see How to convert ppt or pdf files to png images using Node JS.

How to convert the pdf files to png images using nodejs

Problem Statement:-

How to convert PPT or PDF files to PNG Images using Node.js

If you’re not familiar with what PPT or PDF is, let me give you a quick glance.
PPT is Microsoft PowerPoint’s presentation file format. Text, data, charts, graphs, music, and other multimedia files can all be saved with this file extension. Whereas, PDF (Portable Document Format) is a universally compatible file format based on PostScript. However, PDFs are hard to edit, and sometimes it is a challenge to even extract information.
PNG file is a Portable Network Graphics file that supports transparency and stores images using less data compression. It is notable for being high quality, widely supported.

Description of the Issue:-

I was working on a project for one of our clients. As a part of the new feature addition, our client wishes to have specific functionality, which is converting a pdf or ppt/pptx file to separate images. Implementing this feature in the application was a bit challenging.

The Solution Offered:-

After conducting intense research, I found a way to integrate this feature into the App. In the Ubuntu platform, unoconv, spawn and LibreOffice are supported with Node JS. Utilizing this platform enables us to convert ppt or pdf files to png images efficiently.

  • unoconv is a command-line program primarily used to convert between different office document file formats.
  • Spawn is a postfix external command spawner.
  • LibreOffice is an office productivity software suite that is a great alternative to the Microsoft Office Suite of tools.

These are the step by step guide,

Step 01: Install node js
sudo apt install Nodejs
Step 02: Install npm
sudo apt install npm
Step 03: Install unoconv (universal convertor)
sudo apt-get install unoconv
Step04: Install libreoffice
sudo apt-get install libreoffice
Step 05: Install pdftoppm
sudo apt-get install poppler-utils
Step 06: Allow your root paths
sudo npm install -g --unsafe-perm=true --allow-root
Step 07: Install
sudo apt-get install poppler-utils
Step 08: Install child-process and import
npm i child_process
Step 09: Convert ppt to pdf command
unoconv --export Quality=100 samplepptx.pptx samplepptx.pdf
Note:- Make sure pdf name is same as ppt name
Step 10: Convert pdf to png command
pdftoppm samplepptx.pdf output -png
Note:- output is the destination folder
Step 11: Then use the below functions to convert ppt to png and pdf to png
PPT files first convert to pdf and then convert to png images.
Pdf files directly convert to png images.
Platforms (Web, Mobile, Etc.) – Web
Technologies or frameworks or tools – NodeJs, NestJs
Platforms (Web, Mobile, Etc.) – Ubuntu
Soft Suave is a leading software provider that allows you to hire NodeJS developers with 5+ years of experience. They have immense technical skills and knowledge that help us to develop highly interactive Apps with limited budget and time. Plus, they can effectively work with top NodeJS tools like Express.js,, Meteor, Keystone, Koa.js, PM2, Electrode.js, and Babel.