mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-07-05 17:48:38 +00:00
..
This commit is contained in:
parent
8c5851863c
commit
6ae97943df
|
@ -62,10 +62,6 @@ HTMLRenderer::~HTMLRenderer()
|
||||||
delete [] width_list;
|
delete [] width_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GBool annot_cb(Annot *, void *) {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
void HTMLRenderer::process(PDFDoc *doc)
|
void HTMLRenderer::process(PDFDoc *doc)
|
||||||
{
|
{
|
||||||
cur_doc = doc;
|
cur_doc = doc;
|
||||||
|
@ -115,7 +111,7 @@ void HTMLRenderer::process(PDFDoc *doc)
|
||||||
BackgroundRenderer * bg_renderer = nullptr;
|
BackgroundRenderer * bg_renderer = nullptr;
|
||||||
if(param->process_nontext)
|
if(param->process_nontext)
|
||||||
{
|
{
|
||||||
bg_renderer = new BackgroundRenderer();
|
bg_renderer = new BackgroundRenderer(param);
|
||||||
bg_renderer->startDoc(doc);
|
bg_renderer->startDoc(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,19 +130,11 @@ void HTMLRenderer::process(PDFDoc *doc)
|
||||||
|
|
||||||
if(param->process_nontext)
|
if(param->process_nontext)
|
||||||
{
|
{
|
||||||
doc->displayPage(bg_renderer, i, param->h_dpi, param->v_dpi,
|
auto fn = str_fmt("%s/p%x.png", (param->single_html ? param->tmp_dir : param->dest_dir).c_str(), i);
|
||||||
0, true, false, false,
|
if(param->single_html)
|
||||||
nullptr, nullptr, &annot_cb, nullptr);
|
add_tmp_file((char*)fn);
|
||||||
|
|
||||||
{
|
bg_renderer->render_page(doc, i, (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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
doc->displayPage(this, i,
|
doc->displayPage(this, i,
|
||||||
|
|
|
@ -4,10 +4,14 @@
|
||||||
* Copyright (C) 2012 Lu Wang <coolwanglu@gmail.com>
|
* Copyright (C) 2012 Lu Wang <coolwanglu@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <PDFDoc.h>
|
||||||
|
|
||||||
#include "SplashBackgroundRenderer.h"
|
#include "SplashBackgroundRenderer.h"
|
||||||
|
|
||||||
namespace pdf2htmlEX {
|
namespace pdf2htmlEX {
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
const SplashColor SplashBackgroundRenderer::white = {255,255,255};
|
const SplashColor SplashBackgroundRenderer::white = {255,255,255};
|
||||||
|
|
||||||
void SplashBackgroundRenderer::drawChar(GfxState *state, double x, double y,
|
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);
|
// 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
|
} // namespace pdf2htmlEX
|
||||||
|
|
|
@ -10,9 +10,13 @@
|
||||||
#ifndef SPLASH_BACKGROUND_RENDERER_H__
|
#ifndef SPLASH_BACKGROUND_RENDERER_H__
|
||||||
#define SPLASH_BACKGROUND_RENDERER_H__
|
#define SPLASH_BACKGROUND_RENDERER_H__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <splash/SplashBitmap.h>
|
#include <splash/SplashBitmap.h>
|
||||||
#include <SplashOutputDev.h>
|
#include <SplashOutputDev.h>
|
||||||
|
|
||||||
|
#include "Param.h"
|
||||||
|
|
||||||
namespace pdf2htmlEX {
|
namespace pdf2htmlEX {
|
||||||
|
|
||||||
// Based on BackgroundRenderer from poppler
|
// Based on BackgroundRenderer from poppler
|
||||||
|
@ -21,8 +25,9 @@ class SplashBackgroundRenderer : public SplashOutputDev
|
||||||
public:
|
public:
|
||||||
static const SplashColor white;
|
static const SplashColor white;
|
||||||
|
|
||||||
SplashBackgroundRenderer()
|
SplashBackgroundRenderer(const Param * param)
|
||||||
: SplashOutputDev(splashModeRGB8, 4, gFalse, (SplashColorPtr)&white, gTrue, gTrue)
|
: SplashOutputDev(splashModeRGB8, 4, gFalse, (SplashColorPtr)&white, gTrue, gTrue)
|
||||||
|
, param(param)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual ~SplashBackgroundRenderer() { }
|
virtual ~SplashBackgroundRenderer() { }
|
||||||
|
@ -31,6 +36,11 @@ public:
|
||||||
double dx, double dy,
|
double dx, double dy,
|
||||||
double originX, double originY,
|
double originX, double originY,
|
||||||
CharCode code, int nBytes, Unicode *u, int uLen);
|
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
|
} // namespace pdf2htmlEX
|
||||||
|
|
Loading…
Reference in New Issue
Block a user