2012-10-02 12:41:39 +00:00
|
|
|
/*
|
|
|
|
* Splash Background renderer
|
|
|
|
* Render all those things not supported as Image, with Splash
|
|
|
|
*
|
2013-09-18 10:01:56 +00:00
|
|
|
* Copyright (C) 2012,2013 Lu Wang <coolwanglu@gmail.com>
|
2012-10-02 12:41:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-10-02 12:56:40 +00:00
|
|
|
#ifndef SPLASH_BACKGROUND_RENDERER_H__
|
|
|
|
#define SPLASH_BACKGROUND_RENDERER_H__
|
2012-10-02 12:41:39 +00:00
|
|
|
|
2012-10-02 13:11:00 +00:00
|
|
|
#include <string>
|
|
|
|
|
2012-10-02 12:41:39 +00:00
|
|
|
#include <splash/SplashBitmap.h>
|
|
|
|
#include <SplashOutputDev.h>
|
|
|
|
|
2013-09-16 12:39:53 +00:00
|
|
|
#include "pdf2htmlEX-config.h"
|
|
|
|
|
2012-10-02 13:11:00 +00:00
|
|
|
#include "Param.h"
|
2012-11-29 09:28:05 +00:00
|
|
|
#include "HTMLRenderer/HTMLRenderer.h"
|
2012-10-02 13:11:00 +00:00
|
|
|
|
2012-10-02 12:41:39 +00:00
|
|
|
namespace pdf2htmlEX {
|
|
|
|
|
|
|
|
// Based on BackgroundRenderer from poppler
|
2013-09-18 10:01:56 +00:00
|
|
|
class SplashBackgroundRenderer : public BackgroundRenderer, SplashOutputDev
|
2012-10-02 12:41:39 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-10-02 12:56:40 +00:00
|
|
|
static const SplashColor white;
|
2014-06-08 04:43:20 +00:00
|
|
|
//format: "png" or "jpg", or "" for a default format
|
|
|
|
SplashBackgroundRenderer(const std::string & format, HTMLRenderer * html_renderer, const Param & param);
|
2012-10-02 12:56:40 +00:00
|
|
|
|
|
|
|
virtual ~SplashBackgroundRenderer() { }
|
2013-09-16 08:30:00 +00:00
|
|
|
|
2013-09-18 10:01:56 +00:00
|
|
|
virtual void init(PDFDoc * doc);
|
2014-06-08 04:43:20 +00:00
|
|
|
virtual bool render_page(PDFDoc * doc, int pageno);
|
2013-09-18 10:01:56 +00:00
|
|
|
virtual void embed_image(int pageno);
|
|
|
|
|
2013-09-18 21:56:57 +00:00
|
|
|
// Does this device use beginType3Char/endType3Char? Otherwise,
|
|
|
|
// text in Type 3 fonts will be drawn with drawChar/drawString.
|
|
|
|
virtual GBool interpretType3Chars() { return !param.process_type3; }
|
|
|
|
|
2013-09-16 12:39:53 +00:00
|
|
|
#if POPPLER_OLDER_THAN_0_23_0
|
|
|
|
virtual void startPage(int pageNum, GfxState *state);
|
|
|
|
#else
|
2013-09-16 08:30:00 +00:00
|
|
|
virtual void startPage(int pageNum, GfxState *state, XRef *xrefA);
|
2013-09-16 12:39:53 +00:00
|
|
|
#endif
|
2012-10-02 12:41:39 +00:00
|
|
|
|
|
|
|
virtual void drawChar(GfxState *state, double x, double y,
|
|
|
|
double dx, double dy,
|
|
|
|
double originX, double originY,
|
|
|
|
CharCode code, int nBytes, Unicode *u, int uLen);
|
2012-10-02 13:11:00 +00:00
|
|
|
|
2012-10-03 14:46:27 +00:00
|
|
|
virtual void stroke(GfxState *state) {
|
|
|
|
if(!html_renderer->can_stroke(state))
|
|
|
|
SplashOutputDev::stroke(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void fill(GfxState *state) {
|
|
|
|
if(!html_renderer->can_fill(state))
|
|
|
|
SplashOutputDev::fill(state);
|
|
|
|
}
|
|
|
|
|
2012-10-02 13:11:00 +00:00
|
|
|
protected:
|
2013-09-18 10:01:56 +00:00
|
|
|
void dump_image(const char * filename, int x1, int y1, int x2, int y2);
|
2012-10-03 14:46:27 +00:00
|
|
|
HTMLRenderer * html_renderer;
|
2013-04-06 09:01:05 +00:00
|
|
|
const Param & param;
|
2014-06-06 18:01:10 +00:00
|
|
|
std::string format;
|
2012-10-02 12:41:39 +00:00
|
|
|
};
|
|
|
|
|
2012-10-02 12:56:40 +00:00
|
|
|
} // namespace pdf2htmlEX
|
2012-10-02 12:41:39 +00:00
|
|
|
|
2012-10-02 12:56:40 +00:00
|
|
|
#endif // SPLASH_BACKGROUND_RENDERER_H__
|