diff options
author | Stéfan van der Walt <sjvdwalt@gmail.com> | 2020-08-03 21:57:16 +0000 |
---|---|---|
committer | Albert Astals Cid <tsdgeos@yahoo.es> | 2020-08-03 21:57:16 +0000 |
commit | eb3447e579aeeb88847196e8bee359e1e737746f (patch) | |
tree | 449a13784b72c6a377cf04dd8321cc428c2178d0 | |
parent | 6307b5c229d11690b8ed9d11bdaec48cb470c51e (diff) |
pdftoppm: report error and exit if output file cannot be written
-rw-r--r-- | utils/pdftoppm.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/utils/pdftoppm.cc b/utils/pdftoppm.cc index ebb1c6d4..80e495d2 100644 --- a/utils/pdftoppm.cc +++ b/utils/pdftoppm.cc @@ -56,6 +56,7 @@ #include "PDFDocFactory.h" #include "splash/SplashBitmap.h" #include "splash/Splash.h" +#include "splash/SplashErrorCodes.h" #include "SplashOutputDev.h" #include "Win32Console.h" #include "numberofcharacters.h" @@ -278,16 +279,22 @@ static void savePageSlice(PDFDoc *doc, SplashOutputDev *splashOut, int pg, int x params.tiffCompression.Set(TiffCompressionStr); if (ppmFile != nullptr) { + SplashError e; + if (png) { - bitmap->writeImgFile(splashFormatPng, ppmFile, x_resolution, y_resolution); + e = bitmap->writeImgFile(splashFormatPng, ppmFile, x_resolution, y_resolution); } else if (jpeg) { - bitmap->writeImgFile(splashFormatJpeg, ppmFile, x_resolution, y_resolution, ¶ms); + e = bitmap->writeImgFile(splashFormatJpeg, ppmFile, x_resolution, y_resolution, ¶ms); } else if (jpegcmyk) { - bitmap->writeImgFile(splashFormatJpegCMYK, ppmFile, x_resolution, y_resolution, ¶ms); + e = bitmap->writeImgFile(splashFormatJpegCMYK, ppmFile, x_resolution, y_resolution, ¶ms); } else if (tiff) { - bitmap->writeImgFile(splashFormatTiff, ppmFile, x_resolution, y_resolution, ¶ms); + e = bitmap->writeImgFile(splashFormatTiff, ppmFile, x_resolution, y_resolution, ¶ms); } else { - bitmap->writePNMFile(ppmFile); + e = bitmap->writePNMFile(ppmFile); + } + if (e != splashOk) { + fprintf(stderr, "Could not write image to %s; exiting\n", ppmFile); + exit(EXIT_FAILURE); } } else { #ifdef _WIN32 |