From e04b5c5948a24e4da205e573170186b72af0b845 Mon Sep 17 00:00:00 2001 From: Vilius Sutkus '89 Date: Wed, 27 Dec 2023 06:14:07 +0200 Subject: [PATCH] Remove some lines from pdf2htmlEX dump-image patch No need to check if jpeg or png support is compiled in, poppler needs to check that --- .../patches/0.18.8.rc2/dump-image.patch | 74 ++++++++++++------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/pdf2htmlEX/patches/0.18.8.rc2/dump-image.patch b/pdf2htmlEX/patches/0.18.8.rc2/dump-image.patch index 97ec03d..b1195cf 100644 --- a/pdf2htmlEX/patches/0.18.8.rc2/dump-image.patch +++ b/pdf2htmlEX/patches/0.18.8.rc2/dump-image.patch @@ -1,15 +1,51 @@ --- pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.cc 2020-08-19 23:43:25.000000000 +0300 +++ pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.cc 2023-12-27 04:19:36.091000000 +0200 -@@ -18,6 +18,8 @@ - #include "util/const.h" +@@ -5,26 +5,17 @@ + */ - #include "SplashBackgroundRenderer.h" -+#include + #include +-#include +-#include + + #include +-#include +-#include +-#include +-#include +#include + #include "Base64Stream.h" +-#include "util/const.h" +- + #include "SplashBackgroundRenderer.h" + namespace pdf2htmlEX { -@@ -124,27 +126,39 @@ + using std::string; + using std::ifstream; +-using std::vector; +-using std::unique_ptr; + + const SplashColor SplashBackgroundRenderer::white = {255,255,255}; + +@@ -35,6 +26,7 @@ + , format(imgFormat) + { + bool supported = false; ++// ENABLE_LIBPNG and ENABLE_LIBJPEG are defines coming in from poppler-config.h + #ifdef ENABLE_LIBPNG + if (format.empty()) + format = "png"; +@@ -47,7 +39,7 @@ + #endif + if (!supported) + { +- throw string("Image format not supported: ") + format; ++ throw string("Image format not supported by Poppler: ") + format; + } + } + +@@ -124,27 +116,26 @@ void SplashBackgroundRenderer::embed_image(int pageno) { @@ -17,7 +53,7 @@ - int xmin, xmax, ymin, ymax; -// poppler-0.84.0 hack to recover from the removal of *ModRegion tracking -// -- auto * bitmap = getBitmap(); + auto * bitmap = getBitmap(); - xmin = 0; - xmax = bitmap->getWidth(); - ymin = 0; @@ -25,7 +61,6 @@ -// -// end of hack - -+ auto * bitmap = getBitmap(); // dump the background image only when it is not empty - if((xmin <= xmax) && (ymin <= ymax)) + if(bitmap->getWidth() >= 0 && bitmap->getHeight() >= 0) @@ -35,36 +70,23 @@ if(param.embed_image) - html_renderer->tmp_files.add((char*)fn); + html_renderer->tmp_files.add((const char *)fn); - -- dump_image((char*)fn, xmin, ymin, xmax, ymax); ++ + SplashImageFileFormat splashImageFileFormat; -+ if(false) { } -+#ifdef ENABLE_LIBPNG -+ else if(format == "png") -+ { ++ if(format == "png") + splashImageFileFormat = splashFormatPng; -+ } -+#endif -+#ifdef ENABLE_LIBJPEG + else if(format == "jpg") -+ { + splashImageFileFormat = splashFormatJpeg; -+ } -+#endif + else -+ { + throw string("Image format not supported: ") + format; -+ } -+ + +- dump_image((char*)fn, xmin, ymin, xmax, ymax); + SplashError e = bitmap->writeImgFile(splashImageFileFormat, (const char *)fn, param.actual_dpi, param.actual_dpi); + if (e != splashOk) -+ { + throw string("Cannot write background image. SplashErrorCode: ") + std::to_string(e); -+ } } double h_scale = html_renderer->text_zoom_factor() * DEFAULT_DPI / param.actual_dpi; -@@ -154,10 +168,10 @@ +@@ -154,10 +145,10 @@ auto & all_manager = html_renderer->all_manager; f_page << "