Designer/Developer at MPG·
Needs advice
on
ImageMagickImageMagick
and
PHPPHP

Hi! I was looking into ImageMagick to create a JPG on the fly from a PDF file in an HTML/PHP project and found out it had to be installed on the server. I was wondering if there are any alternatives that can be run from the webpage without installations on the server-side.

This is my first post in stackshare, so please allow me to apologize if this post is in the wrong place or written incorrectly! Don't shoot me :-)

READ LESS
6 upvotes·16.2K views
Replies (6)
Recommends
on
PDF.js

Hi Nicolas,

I think you need something like this: https://gist.github.com/imolorhe/f8794d3bb55e1a8065b23bcd0efeebe1 Using pdf.js you can convert each page in pdf to a corresponding image. I have not tested this myself, but PDF. js has been around for sometime and should work for you converting the pdf to image completely on the client side.

READ MORE
5 upvotes·1 comment·7.6K views
Nicolás Tomé Miller
Nicolás Tomé Miller
·
August 7th 2020 at 7:20PM

Hi Raj, Thanks for your comment. This look very promising, I will look into it

·
Reply
Recommends
on
PDF.js

Please follow the tutorial in the link. It will enable you to convert pdf file to png or jpeg using only JavaScript Load the file using pdf.js Create a button to the function Button is: "download-image"

// Download button (PNG) $("#download-image").on('click', function() { $(this).attr('href', $('#pdf-canvas').get(0).toDataURL());

// Specfify download option with name
$(this).attr('download', 'page.png');

});

// Download button (JPEG with quality 80%) $("#download-image").on('click', function() { $(this).attr('href', $('#pdf-canvas').get(0).toDataURL("image/jpeg", 0.8));

// Specfify download option with name
$(this).attr('download', 'page.jpg');

})

READ MORE
How to Convert PDF to Image (JPEG / PNG) in Javascript using PDF.JS Library (usefulangle.com)
5 upvotes·6.3K views
View all (6)
Avatar of Nicolás Tomé Miller

Nicolás Tomé Miller

Designer/Developer at MPG