1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 13:00:08 +00:00
This commit is contained in:
Lu Wang 2012-10-02 21:11:00 +08:00
parent 8c5851863c
commit 6ae97943df
3 changed files with 35 additions and 18 deletions

View File

@ -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,

View File

@ -4,10 +4,14 @@
* Copyright (C) 2012 Lu Wang <coolwanglu@gmail.com>
*/
#include <PDFDoc.h>
#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

View File

@ -10,9 +10,13 @@
#ifndef SPLASH_BACKGROUND_RENDERER_H__
#define SPLASH_BACKGROUND_RENDERER_H__
#include <string>
#include <splash/SplashBitmap.h>
#include <SplashOutputDev.h>
#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