[poppler] utils/pdftoppm.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Aug 3 21:57:18 UTC 2020
utils/pdftoppm.cc | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
New commits:
commit eb3447e579aeeb88847196e8bee359e1e737746f
Author: Stéfan van der Walt <sjvdwalt at gmail.com>
Date: Mon Aug 3 21:57:16 2020 +0000
pdftoppm: report error and exit if output file cannot be written
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
More information about the poppler
mailing list