mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
working on integrating splash
This commit is contained in:
parent
8f52d75fef
commit
5f5747738f
2
TODO
2
TODO
@ -1,3 +1,5 @@
|
|||||||
|
don't dump image when there is nothing
|
||||||
|
|
||||||
Integrate splash/cairo
|
Integrate splash/cairo
|
||||||
native support for image
|
native support for image
|
||||||
native support for draw
|
native support for draw
|
||||||
|
@ -236,11 +236,26 @@ GBool HTMLRenderer::axialShadedFill(GfxState *state, GfxAxialShading *shading, d
|
|||||||
|
|
||||||
//TODO track state
|
//TODO track state
|
||||||
//TODO connection style
|
//TODO connection style
|
||||||
void HTMLRenderer::css_draw(GfxState *state, bool fill)
|
bool HTMLRenderer::css_do_path(GfxState *state, bool fill, bool test_only)
|
||||||
{
|
{
|
||||||
if(!(param->css_draw)) return;
|
if(!(param->css_draw)) return false;
|
||||||
|
|
||||||
GfxPath * path = state->getPath();
|
GfxPath * path = state->getPath();
|
||||||
|
/*
|
||||||
|
* capacity check
|
||||||
|
*/
|
||||||
|
for(int i = 0; i < path->getNumSubpaths(); ++i)
|
||||||
|
{
|
||||||
|
GfxSubpath * subpath = path->getSubpath(i);
|
||||||
|
if(!(is_horizontal_line(subpath)
|
||||||
|
|| is_vertical_line(subpath)
|
||||||
|
|| is_rectangle(subpath)))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(test_only)
|
||||||
|
return true;
|
||||||
|
|
||||||
for(int i = 0; i < path->getNumSubpaths(); ++i)
|
for(int i = 0; i < path->getNumSubpaths(); ++i)
|
||||||
{
|
{
|
||||||
GfxSubpath * subpath = path->getSubpath(i);
|
GfxSubpath * subpath = path->getSubpath(i);
|
||||||
@ -279,7 +294,6 @@ void HTMLRenderer::css_draw(GfxState *state, bool fill)
|
|||||||
}
|
}
|
||||||
else if(is_rectangle(subpath))
|
else if(is_rectangle(subpath))
|
||||||
{
|
{
|
||||||
close_text_line();
|
|
||||||
double x1 = subpath->getX(0);
|
double x1 = subpath->getX(0);
|
||||||
double x2 = subpath->getX(2);
|
double x2 = subpath->getX(2);
|
||||||
double y1 = subpath->getY(0);
|
double y1 = subpath->getY(0);
|
||||||
@ -318,7 +332,12 @@ void HTMLRenderer::css_draw(GfxState *state, bool fill)
|
|||||||
lw, lw_count,
|
lw, lw_count,
|
||||||
ps, pf);
|
ps, pf);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTMLRenderer::css_draw_rectangle(double x, double y, double w, double h, const double * tm,
|
void HTMLRenderer::css_draw_rectangle(double x, double y, double w, double h, const double * tm,
|
||||||
|
@ -111,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(param);
|
bg_renderer = new BackgroundRenderer(this, param);
|
||||||
bg_renderer->startDoc(doc);
|
bg_renderer->startDoc(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class HTMLRenderer : public OutputDev
|
|||||||
// Does this device use functionShadedFill(), axialShadedFill(), and
|
// Does this device use functionShadedFill(), axialShadedFill(), and
|
||||||
// radialShadedFill()? If this returns false, these shaded fills
|
// radialShadedFill()? If this returns false, these shaded fills
|
||||||
// will be reduced to a series of other drawing operations.
|
// will be reduced to a series of other drawing operations.
|
||||||
virtual GBool useShadedFills(int type) { return type == 2; }
|
virtual GBool useShadedFills(int type) { return (type == 2) ? gTrue: gFalse; }
|
||||||
|
|
||||||
|
|
||||||
// Does this device use beginType3Char/endType3Char? Otherwise,
|
// Does this device use beginType3Char/endType3Char? Otherwise,
|
||||||
@ -90,7 +90,7 @@ class HTMLRenderer : public OutputDev
|
|||||||
virtual GBool interpretType3Chars() { return gFalse; }
|
virtual GBool interpretType3Chars() { return gFalse; }
|
||||||
|
|
||||||
// Does this device need non-text content?
|
// Does this device need non-text content?
|
||||||
virtual GBool needNonText() { return gTrue; }
|
virtual GBool needNonText() { return (param->process_nontext) ? gTrue: gFalse; }
|
||||||
|
|
||||||
virtual void setDefaultCTM(double *ctm);
|
virtual void setDefaultCTM(double *ctm);
|
||||||
|
|
||||||
@ -104,6 +104,13 @@ class HTMLRenderer : public OutputDev
|
|||||||
* To optmize false alarms
|
* To optmize false alarms
|
||||||
* We just mark as changed, and recheck if they have been changed when we are about to output a new string
|
* We just mark as changed, and recheck if they have been changed when we are about to output a new string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ugly implementation of save/restore
|
||||||
|
*/
|
||||||
|
virtual void saveState(GfxState * state) {updateAll(state);}
|
||||||
|
virtual void restoreState(GfxState * state) {updateAll(state);}
|
||||||
|
|
||||||
virtual void updateAll(GfxState * state);
|
virtual void updateAll(GfxState * state);
|
||||||
|
|
||||||
virtual void updateRise(GfxState * state);
|
virtual void updateRise(GfxState * state);
|
||||||
@ -129,12 +136,16 @@ class HTMLRenderer : public OutputDev
|
|||||||
|
|
||||||
virtual void drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, GBool interpolate, int *maskColors, GBool inlineImg);
|
virtual void drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, GBool interpolate, int *maskColors, GBool inlineImg);
|
||||||
|
|
||||||
virtual void stroke(GfxState *state) { css_draw(state, false); }
|
virtual void stroke(GfxState *state) { css_do_path(state, false); }
|
||||||
virtual void fill(GfxState *state) { css_draw(state, true); }
|
virtual void fill(GfxState *state) { css_do_path(state, true); }
|
||||||
virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax);
|
virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax);
|
||||||
|
|
||||||
virtual void processLink(AnnotLink * al);
|
virtual void processLink(AnnotLink * al);
|
||||||
|
|
||||||
|
/* capacity test */
|
||||||
|
bool can_stroke(GfxState *state) { return css_do_path(state, false, true); }
|
||||||
|
bool can_fill(GfxState *state) { return css_do_path(state, true, true); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
// misc
|
// misc
|
||||||
@ -208,7 +219,10 @@ class HTMLRenderer : public OutputDev
|
|||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
// CSS drawing
|
// CSS drawing
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
void css_draw(GfxState *state, bool fill);
|
/*
|
||||||
|
* test_only is for capacity check
|
||||||
|
*/
|
||||||
|
bool css_do_path(GfxState *state, bool fill, bool test_only = false);
|
||||||
/*
|
/*
|
||||||
* coordinates are to transformed by state->getCTM()
|
* coordinates are to transformed by state->getCTM()
|
||||||
* (x,y) should be the bottom-left corner INCLUDING border
|
* (x,y) should be the bottom-left corner INCLUDING border
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <splash/SplashBitmap.h>
|
#include <splash/SplashBitmap.h>
|
||||||
#include <SplashOutputDev.h>
|
#include <SplashOutputDev.h>
|
||||||
|
|
||||||
|
#include "HTMLRenderer.h"
|
||||||
#include "Param.h"
|
#include "Param.h"
|
||||||
|
|
||||||
namespace pdf2htmlEX {
|
namespace pdf2htmlEX {
|
||||||
@ -25,8 +26,9 @@ class SplashBackgroundRenderer : public SplashOutputDev
|
|||||||
public:
|
public:
|
||||||
static const SplashColor white;
|
static const SplashColor white;
|
||||||
|
|
||||||
SplashBackgroundRenderer(const Param * param)
|
SplashBackgroundRenderer(HTMLRenderer * html_renderer, const Param * param)
|
||||||
: SplashOutputDev(splashModeRGB8, 4, gFalse, (SplashColorPtr)&white, gTrue, gTrue)
|
: SplashOutputDev(splashModeRGB8, 4, gFalse, (SplashColorPtr)&white, gTrue, gTrue)
|
||||||
|
, html_renderer(html_renderer)
|
||||||
, param(param)
|
, param(param)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@ -37,9 +39,20 @@ public:
|
|||||||
double originX, double originY,
|
double originX, double originY,
|
||||||
CharCode code, int nBytes, Unicode *u, int uLen);
|
CharCode code, int nBytes, Unicode *u, int uLen);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
void render_page(PDFDoc * doc, int pageno, const std::string & filename);
|
void render_page(PDFDoc * doc, int pageno, const std::string & filename);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
HTMLRenderer * html_renderer;
|
||||||
const Param * param;
|
const Param * param;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user