0

I use this library pdftoppm that I installed in CentOS 7 from official repository:

sudo yum install poppler-utils

If I run the software to convert PDF file pages to images, all works well. My issue is to try to cover a case when the conversion fails, so I was thinking that the library will throw an error if something goes wrong but it always sends empty output.

Here is a successful command:

pdftoppm -png -rx 300 -ry 300 /home/user/PDF_FILE_NAME.pdf /home/user/PDF_FILE_NAME

All works well I can see my images inside /home/user/PDF_FILE_NAME

Now, if I change the destination to something that does not exist like /home/userXXXX/PDF_FILE_NAME nothing happens, no images are created of course which is normal but at least I should get some errors? Am I wrong or is this how this library works please?

Thanks.

Dev Dev
  • 314
  • 4
  • 17
  • what does `echo $?` show right after that last command? – robertklep Aug 15 '22 at 17:12
  • It shows 0 for both cases, my valid output path and wrong path too. – Dev Dev Aug 15 '22 at 17:17
  • I can only check on macOS and Ubuntu 22.04, and on both `pdftoppm` outputs an error when I try to make it write to a non-existent directory (_"Could not write image to …; exiting"_). – robertklep Aug 15 '22 at 17:21
  • I'm using a VPS. The output of this command cat /etc/centos-release gives CentOS Linux release 7.9.2009 (Core). Do I have something configured to disable errors which I doubt? – Dev Dev Aug 15 '22 at 17:29
  • I doubt it too. Also, when it fails for me, `$?` equals 1, as expected. Which version of pdftoppm gets installed (`pdftoppm -v`)? My Ubuntu is running 22.02.0, macOS is running 21.07.0. – robertklep Aug 15 '22 at 17:46
  • Sorry for the delay: pdftoppm version 0.26.5 Copyright 2005-2014 The Poppler Developers - http://poppler.freedesktop.org Copyright 1996-2011 Glyph & Cog, LLC – Dev Dev Aug 15 '22 at 18:42
  • That's a _very_ old version. I don't know enough about CentOS to help you out with getting a more recent version installed. – robertklep Aug 15 '22 at 18:46
  • It seems like that is the latest version for CentOS7 https://pkgs.org/download/poppler. – Dev Dev Aug 15 '22 at 19:11
  • As I cannot upgrade my VPS to CentOS8, is there a binary version for poppler please ? – Dev Dev Aug 15 '22 at 19:15
  • I can't help you with that, and it's off-topic for SO. Perhaps ask on superuser.com, hopefully there are more CentOS users there. – robertklep Aug 16 '22 at 06:10

0 Answers0