mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
Merge pull request #379 from duanyao/proof_output
Proof mode: take care of render mode change inside text object; fix line...
This commit is contained in:
commit
10cbf4e5c5
@ -59,23 +59,21 @@ void BackgroundRenderer::proof_begin_text_object(GfxState *state, OutputDev * de
|
|||||||
proof_state->setStrokeColorSpace(new GfxDeviceRGBColorSpace());
|
proof_state->setStrokeColorSpace(new GfxDeviceRGBColorSpace());
|
||||||
}
|
}
|
||||||
|
|
||||||
int render = state->getRender();
|
|
||||||
|
|
||||||
// Save original render mode in proof_state, and restore in proof_end_text_object()
|
// Save original render mode in proof_state, and restore in proof_end_text_object()
|
||||||
// This is due to poppler's OutputDev::updateRender() actually has no effect, we have to
|
// This is due to poppler's OutputDev::updateRender() actually has no effect, we have to
|
||||||
// modify state directly, see proof_begin_string().
|
// modify state directly, see proof_begin_string().
|
||||||
proof_state->setRender(render);
|
proof_state->setRender(state->getRender());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackgroundRenderer::proof_begin_string(GfxState *state, OutputDev * dev)
|
void BackgroundRenderer::proof_begin_string(GfxState *state, OutputDev * dev)
|
||||||
{
|
{
|
||||||
int render = proof_state->getRender();
|
int render = proof_state->getRender();
|
||||||
if (render == 3 || state->getRender() == 3) // hidden
|
if (render == 3) // hidden
|
||||||
return;
|
return;
|
||||||
|
|
||||||
double lx = state->getFontSize() / 50, ly = lx;
|
double lx = state->getFontSize() / 70, ly = lx;
|
||||||
tm_transform(state->getTextMat(), lx, ly, true);
|
tm_transform(state->getTextMat(), lx, ly, true);
|
||||||
proof_state->setLineWidth(std::min(fabs(lx), fabs(ly)));
|
proof_state->setLineWidth(sqrt(lx * lx + ly * ly));
|
||||||
|
|
||||||
static const Color red(1, 0, 0), green(0, 1, 0), blue(0, 0, 1), yellow(1, 1, 0), white(1, 1, 1);
|
static const Color red(1, 0, 0), green(0, 1, 0), blue(0, 0, 1), yellow(1, 1, 0), white(1, 1, 1);
|
||||||
Color fc, sc;
|
Color fc, sc;
|
||||||
@ -111,13 +109,11 @@ void BackgroundRenderer::proof_begin_string(GfxState *state, OutputDev * dev)
|
|||||||
dev->updateStrokeColor(proof_state.get());
|
dev->updateStrokeColor(proof_state.get());
|
||||||
|
|
||||||
state->setRender(2); // fill & stroke
|
state->setRender(2); // fill & stroke
|
||||||
dev->updateRender(state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackgroundRenderer::proof_end_text_object(GfxState *state, OutputDev * dev)
|
void BackgroundRenderer::proof_end_text_object(GfxState *state, OutputDev * dev)
|
||||||
{
|
{
|
||||||
state->setRender(proof_state->getRender());
|
state->setRender(proof_state->getRender());
|
||||||
dev->updateRender(state);
|
|
||||||
dev->updateLineWidth(state);
|
dev->updateLineWidth(state);
|
||||||
dev->updateFillColorSpace(state);
|
dev->updateFillColorSpace(state);
|
||||||
dev->updateStrokeColorSpace(state);
|
dev->updateStrokeColorSpace(state);
|
||||||
@ -125,4 +121,10 @@ void BackgroundRenderer::proof_end_text_object(GfxState *state, OutputDev * dev)
|
|||||||
dev->updateStrokeColor(state);
|
dev->updateStrokeColor(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BackgroundRenderer::proof_update_render(GfxState *state, OutputDev * dev)
|
||||||
|
{
|
||||||
|
// Save render mode in proof_state in cases it is changed inside a text object
|
||||||
|
proof_state->setRender(state->getRender());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace pdf2htmlEX
|
} // namespace pdf2htmlEX
|
||||||
|
@ -42,6 +42,7 @@ protected:
|
|||||||
void proof_begin_text_object(GfxState * state, OutputDev * dev);
|
void proof_begin_text_object(GfxState * state, OutputDev * dev);
|
||||||
void proof_begin_string(GfxState * state, OutputDev * dev);
|
void proof_begin_string(GfxState * state, OutputDev * dev);
|
||||||
void proof_end_text_object(GfxState * state, OutputDev * dev);
|
void proof_end_text_object(GfxState * state, OutputDev * dev);
|
||||||
|
void proof_update_render(GfxState * state, OutputDev * dev);
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<GfxState> proof_state;
|
std::unique_ptr<GfxState> proof_state;
|
||||||
};
|
};
|
||||||
|
@ -86,6 +86,13 @@ void CairoBackgroundRenderer::endTextObject(GfxState *state)
|
|||||||
CairoOutputDev::endTextObject(state);
|
CairoOutputDev::endTextObject(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CairoBackgroundRenderer::updateRender(GfxState *state)
|
||||||
|
{
|
||||||
|
if (param.proof == 2)
|
||||||
|
proof_update_render(state, this);
|
||||||
|
CairoOutputDev::updateRender(state);
|
||||||
|
}
|
||||||
|
|
||||||
void CairoBackgroundRenderer::init(PDFDoc * doc)
|
void CairoBackgroundRenderer::init(PDFDoc * doc)
|
||||||
{
|
{
|
||||||
startDoc(doc);
|
startDoc(doc);
|
||||||
|
@ -48,6 +48,7 @@ public:
|
|||||||
void beginTextObject(GfxState *state);
|
void beginTextObject(GfxState *state);
|
||||||
void beginString(GfxState *state, GooString * str);
|
void beginString(GfxState *state, GooString * str);
|
||||||
void endTextObject(GfxState *state);
|
void endTextObject(GfxState *state);
|
||||||
|
void updateRender(GfxState *state);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setMimeData(Stream *str, Object *ref, cairo_surface_t *image);
|
virtual void setMimeData(Stream *str, Object *ref, cairo_surface_t *image);
|
||||||
|
@ -111,6 +111,13 @@ void SplashBackgroundRenderer::endTextObject(GfxState *state)
|
|||||||
SplashOutputDev::endTextObject(state);
|
SplashOutputDev::endTextObject(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SplashBackgroundRenderer::updateRender(GfxState *state)
|
||||||
|
{
|
||||||
|
if (param.proof == 2)
|
||||||
|
proof_update_render(state, this);
|
||||||
|
SplashOutputDev::updateRender(state);
|
||||||
|
}
|
||||||
|
|
||||||
void SplashBackgroundRenderer::init(PDFDoc * doc)
|
void SplashBackgroundRenderer::init(PDFDoc * doc)
|
||||||
{
|
{
|
||||||
startDoc(doc);
|
startDoc(doc);
|
||||||
|
@ -64,6 +64,7 @@ public:
|
|||||||
void beginTextObject(GfxState *state);
|
void beginTextObject(GfxState *state);
|
||||||
void beginString(GfxState *state, GooString * str);
|
void beginString(GfxState *state, GooString * str);
|
||||||
void endTextObject(GfxState *state);
|
void endTextObject(GfxState *state);
|
||||||
|
void updateRender(GfxState *state);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void dump_image(const char * filename, int x1, int y1, int x2, int y2);
|
void dump_image(const char * filename, int x1, int y1, int x2, int y2);
|
||||||
|
Loading…
Reference in New Issue
Block a user