1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 13:00:08 +00:00

initial pass at updating pdf2htmlEX to use poppler-0.83.0

This commit is contained in:
Stephen Gaito 2019-12-13 11:27:54 +00:00
parent 59dcc07638
commit a8323f1c16
16 changed files with 37 additions and 24 deletions

View File

@ -82,9 +82,11 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Woverloaded-virtual")
# CYGWIN or GCC 4.5.x bug # CYGWIN or GCC 4.5.x bug
if(CYGWIN) if(CYGWIN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x") # was: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
# the following change is untested:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
else() else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -pthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread")
endif() endif()
# check the C++11 features we need # check the C++11 features we need

View File

@ -46,7 +46,7 @@ CairoBackgroundRenderer::~CairoBackgroundRenderer()
void CairoBackgroundRenderer::drawChar(GfxState *state, double x, double y, void CairoBackgroundRenderer::drawChar(GfxState *state, double x, double y,
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, const Unicode *u, int uLen)
{ {
// draw characters as image when // draw characters as image when
// - in fallback mode // - in fallback mode

View File

@ -42,7 +42,7 @@ public:
virtual void drawChar(GfxState *state, double x, double y, virtual void drawChar(GfxState *state, double x, double y,
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, const Unicode *u, int uLen);
//for proof //for proof
void beginTextObject(GfxState *state); void beginTextObject(GfxState *state);

View File

@ -65,7 +65,7 @@ void SplashBackgroundRenderer::startPage(int pageNum, GfxState *state, XRef *xre
void SplashBackgroundRenderer::drawChar(GfxState *state, double x, double y, void SplashBackgroundRenderer::drawChar(GfxState *state, double x, double y,
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, const Unicode *u, int uLen)
{ {
if (param.proof || html_renderer->is_char_covered(drawn_char_count)) { if (param.proof || html_renderer->is_char_covered(drawn_char_count)) {
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);

View File

@ -44,7 +44,7 @@ public:
virtual void drawChar(GfxState *state, double x, double y, virtual void drawChar(GfxState *state, double x, double y,
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, const Unicode *u, int uLen);
//for proof //for proof
void beginTextObject(GfxState *state); void beginTextObject(GfxState *state);

View File

@ -136,10 +136,10 @@ void DrawingTracer::restore()
#endif #endif
} }
void DrawingTracer::do_path(GfxState * state, GfxPath * path) void DrawingTracer::do_path(GfxState * state, const GfxPath * path)
{ {
//copy from CairoOutputDev::doPath //copy from CairoOutputDev::doPath
GfxSubpath *subpath; const GfxSubpath *subpath;
int i, j; int i, j;
double x, y; double x, y;
cairo_new_path(cairo); cairo_new_path(cairo);
@ -220,9 +220,9 @@ void DrawingTracer::stroke(GfxState * state)
break; break;
} }
GfxPath * path = state->getPath(); const GfxPath * path = state->getPath();
for (int i = 0; i < path->getNumSubpaths(); ++i) { for (int i = 0; i < path->getNumSubpaths(); ++i) {
GfxSubpath * subpath = path->getSubpath(i); const GfxSubpath * subpath = path->getSubpath(i);
if (subpath->getNumPoints() <= 0) if (subpath->getNumPoints() <= 0)
continue; continue;
double x = subpath->getX(0); double x = subpath->getX(0);

View File

@ -65,7 +65,7 @@ public:
private: private:
void finish(); void finish();
// Following methods operate in user space (just before CTM is applied) // Following methods operate in user space (just before CTM is applied)
void do_path(GfxState * state, GfxPath * path); void do_path(GfxState * state, const GfxPath * path);
void draw_non_char_bbox(GfxState * state, double * bbox, int what); void draw_non_char_bbox(GfxState * state, double * bbox, int what);
void draw_char_bbox(GfxState * state, double * bbox, int inTransparencyGroup); void draw_char_bbox(GfxState * state, double * bbox, int inTransparencyGroup);
// If cairo is available, parameter state is ignored // If cairo is available, parameter state is ignored

View File

@ -156,7 +156,9 @@ struct HTMLRenderer : OutputDev
virtual void drawString(GfxState * state, const GooString * s); virtual void drawString(GfxState * state, const GooString * s);
virtual void drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, bool interpolate, int *maskColors, bool inlineImg); virtual void drawImage(GfxState * state, Object * ref, Stream * str,
int width, int height, GfxImageColorMap * colorMap,
bool interpolate, const int *maskColors, bool inlineImg);
virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
int width, int height, int width, int height,

View File

@ -636,7 +636,8 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
if(mapped_code > max_key) if(mapped_code > max_key)
max_key = mapped_code; max_key = mapped_code;
Unicode u, *pu=&u; Unicode u;
Unicode const *pu=&u;
if(info.use_tounicode) if(info.use_tounicode)
{ {
int n = ctu ? int n = ctu ?

View File

@ -12,7 +12,9 @@
namespace pdf2htmlEX { namespace pdf2htmlEX {
void HTMLRenderer::drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, bool interpolate, int *maskColors, bool inlineImg) void HTMLRenderer::drawImage(GfxState * state, Object * ref, Stream * str,
int width, int height, GfxImageColorMap * colorMap,
bool interpolate, const int *maskColors, bool inlineImg)
{ {
tracer.draw_image(state); tracer.draw_image(state);

View File

@ -74,7 +74,7 @@ void HTMLRenderer::drawString(GfxState * state, const GooString * s)
int uLen; int uLen;
CharCode code; CharCode code;
Unicode *u = nullptr; Unicode const *u = nullptr;
HR_DEBUG(printf("HTMLRenderer::drawString:len=%d\n", len)); HR_DEBUG(printf("HTMLRenderer::drawString:len=%d\n", len));

View File

@ -65,7 +65,7 @@ void Preprocessor::process(PDFDoc * doc)
void Preprocessor::drawChar(GfxState *state, double x, double y, void Preprocessor::drawChar(GfxState *state, double x, double y,
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, const Unicode *u, int uLen)
{ {
GfxFont * font = state->getFont(); GfxFont * font = state->getFont();
if(!font) return; if(!font) return;

View File

@ -39,7 +39,7 @@ public:
virtual void drawChar(GfxState *state, double x, double y, virtual void drawChar(GfxState *state, double x, double y,
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, const Unicode *u, int uLen);
// Start a page. // Start a page.
// UGLY: These 2 versions are for different versions of poppler // UGLY: These 2 versions are for different versions of poppler

View File

@ -407,8 +407,11 @@ int main(int argc, char **argv)
param.tmp_dir.c_str()); param.tmp_dir.c_str());
bool finished = false; bool finished = false;
// read config file // read poppler config file
globalParams = new GlobalParams(!param.poppler_data_dir.empty() ? param.poppler_data_dir.c_str() : NULL); globalParams = std::make_unique<GlobalParams>(
!param.poppler_data_dir.empty() ? param.poppler_data_dir.c_str() : NULL
);
// open PDF file // open PDF file
PDFDoc * doc = nullptr; PDFDoc * doc = nullptr;
try try
@ -435,8 +438,11 @@ int main(int argc, char **argv)
cerr << "Document has copy-protection bit set." << endl; cerr << "Document has copy-protection bit set." << endl;
} }
param.first_page = min<int>(max<int>(param.first_page, 1), doc->getNumPages()); param.first_page =
param.last_page = min<int>(max<int>(param.last_page, param.first_page), doc->getNumPages()); min<int>(max<int>(param.first_page, 1), doc->getNumPages());
param.last_page =
min<int>(max<int>(param.last_page, param.first_page),
doc->getNumPages());
unique_ptr<HTMLRenderer>(new HTMLRenderer(argv[0], param))->process(doc); unique_ptr<HTMLRenderer>(new HTMLRenderer(argv[0], param))->process(doc);
@ -454,7 +460,7 @@ int main(int argc, char **argv)
// clean up // clean up
delete doc; delete doc;
delete globalParams; globalParams.reset();
// check for memory leaks // check for memory leaks
// Poppler Object class (Object.h) no longer has memCheck // Poppler Object class (Object.h) no longer has memCheck

View File

@ -55,7 +55,7 @@ Unicode unicode_from_font (CharCode code, GfxFont * font)
return map_to_private(code); return map_to_private(code);
} }
Unicode check_unicode(Unicode * u, int len, CharCode code, GfxFont * font) Unicode check_unicode(Unicode const * u, int len, CharCode code, GfxFont * font)
{ {
if(len == 0) if(len == 0)
return map_to_private(code); return map_to_private(code);

View File

@ -83,7 +83,7 @@ Unicode unicode_from_font (CharCode code, GfxFont * font);
* if we got multi-unicode values, it might be expanded ligature, try to restore it * if we got multi-unicode values, it might be expanded ligature, try to restore it
* if we cannot figure it out at the end, use a private mapping * if we cannot figure it out at the end, use a private mapping
*/ */
Unicode check_unicode(Unicode * u, int len, CharCode code, GfxFont * font); Unicode check_unicode(Unicode const * u, int len, CharCode code, GfxFont * font);
} // namespace pdf2htmlEX } // namespace pdf2htmlEX