diff --git a/src/HTMLRenderer/general.cc b/src/HTMLRenderer/general.cc
index 427af7b..ea55f72 100644
--- a/src/HTMLRenderer/general.cc
+++ b/src/HTMLRenderer/general.cc
@@ -62,10 +62,6 @@ HTMLRenderer::~HTMLRenderer()
delete [] width_list;
}
-static GBool annot_cb(Annot *, void *) {
- return false;
-};
-
void HTMLRenderer::process(PDFDoc *doc)
{
cur_doc = doc;
@@ -115,7 +111,7 @@ void HTMLRenderer::process(PDFDoc *doc)
BackgroundRenderer * bg_renderer = nullptr;
if(param->process_nontext)
{
- bg_renderer = new BackgroundRenderer();
+ bg_renderer = new BackgroundRenderer(param);
bg_renderer->startDoc(doc);
}
@@ -134,19 +130,11 @@ void HTMLRenderer::process(PDFDoc *doc)
if(param->process_nontext)
{
- doc->displayPage(bg_renderer, i, param->h_dpi, param->v_dpi,
- 0, true, false, false,
- nullptr, nullptr, &annot_cb, nullptr);
+ auto fn = str_fmt("%s/p%x.png", (param->single_html ? param->tmp_dir : param->dest_dir).c_str(), i);
+ if(param->single_html)
+ add_tmp_file((char*)fn);
- {
- auto fn = str_fmt("%s/p%x.png", (param->single_html ? param->tmp_dir : param->dest_dir).c_str(), i);
- if(param->single_html)
- add_tmp_file((char*)fn);
-
- bg_renderer->getBitmap()->writeImgFile(splashFormatPng,
- (char*)fn,
- param->h_dpi, param->v_dpi);
- }
+ bg_renderer->render_page(doc, i, (char*)fn);
}
doc->displayPage(this, i,
diff --git a/src/SplashBackgroundRenderer.cc b/src/SplashBackgroundRenderer.cc
index 4492160..f2d7a85 100644
--- a/src/SplashBackgroundRenderer.cc
+++ b/src/SplashBackgroundRenderer.cc
@@ -4,10 +4,14 @@
* Copyright (C) 2012 Lu Wang
*/
+#include
+
#include "SplashBackgroundRenderer.h"
namespace pdf2htmlEX {
+using std::string;
+
const SplashColor SplashBackgroundRenderer::white = {255,255,255};
void SplashBackgroundRenderer::drawChar(GfxState *state, double x, double y,
@@ -18,4 +22,19 @@ void SplashBackgroundRenderer::drawChar(GfxState *state, double x, double y,
// SplashOutputDev::drawChar(state,x,y,dx,dy,originX,originY,code, nBytes, u, uLen);
}
+static GBool annot_cb(Annot *, void *) {
+ return false;
+};
+
+void SplashBackgroundRenderer::render_page(PDFDoc * doc, int pageno, const string & filename)
+{
+ doc->displayPage(this, pageno, param->h_dpi, param->v_dpi,
+ 0, true, false, false,
+ nullptr, nullptr, &annot_cb, nullptr);
+
+ getBitmap()->writeImgFile(splashFormatPng,
+ (char*)filename.c_str(),
+ param->h_dpi, param->v_dpi);
+}
+
} // namespace pdf2htmlEX
diff --git a/src/include/SplashBackgroundRenderer.h b/src/include/SplashBackgroundRenderer.h
index aced0fb..e56bf1d 100644
--- a/src/include/SplashBackgroundRenderer.h
+++ b/src/include/SplashBackgroundRenderer.h
@@ -10,9 +10,13 @@
#ifndef SPLASH_BACKGROUND_RENDERER_H__
#define SPLASH_BACKGROUND_RENDERER_H__
+#include
+
#include
#include
+#include "Param.h"
+
namespace pdf2htmlEX {
// Based on BackgroundRenderer from poppler
@@ -21,8 +25,9 @@ class SplashBackgroundRenderer : public SplashOutputDev
public:
static const SplashColor white;
- SplashBackgroundRenderer()
+ SplashBackgroundRenderer(const Param * param)
: SplashOutputDev(splashModeRGB8, 4, gFalse, (SplashColorPtr)&white, gTrue, gTrue)
+ , param(param)
{ }
virtual ~SplashBackgroundRenderer() { }
@@ -31,6 +36,11 @@ public:
double dx, double dy,
double originX, double originY,
CharCode code, int nBytes, Unicode *u, int uLen);
+
+ void render_page(PDFDoc * doc, int pageno, const std::string & filename);
+
+protected:
+ const Param * param;
};
} // namespace pdf2htmlEX