For over five days, I have google searched endlessly with no luck for a clean solution on how to convert pdf to image.
I have had to try several npm packages that does not seems to work.
Packages I tried includes
Pdf-proppeler-:which works fine on development but unfortunately does not support Linux so does not work on heroku
Pdf2pic, pdf-image and some others which does not work due to heavy dependencies on graphicmagic, imagemagic and Ghostscript even after installing all dependencies.
Also tried several suggestions from previously asked questions on stackoverflow which does not seem to solve my problem.
Finally I decided to use the imagemagic cmd command
exec(`magick convert ${filename.pdf} -density 300 -quality 100 output.jpg`, {
cwd: uploadPath
}, async (error) => {
if (error) {
return reject(error);
}
});
through the NodeJs child-process exec method which works fine on development but fails on heroku after deployment.
Several attempts of trying to add the imagemagic buildpack to the heroku server has failed.
I need help getting the imagemagic cmd command for the conversation to work on heroku or any cleaner solution.
I’m stuck with this issue