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
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()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread")
endif()
# check the C++11 features we need

View File

@ -46,7 +46,7 @@ CairoBackgroundRenderer::~CairoBackgroundRenderer()
void CairoBackgroundRenderer::drawChar(GfxState *state, double x, double y,
double dx, double dy,
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
// - in fallback mode

View File

@ -42,7 +42,7 @@ public:
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);
CharCode code, int nBytes, const Unicode *u, int uLen);
//for proof
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,
double dx, double dy,
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)) {
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,
double dx, double dy,
double originX, double originY,
CharCode code, int nBytes, Unicode *u, int uLen);
CharCode code, int nBytes, const Unicode *u, int uLen);
//for proof
void beginTextObject(GfxState *state);

View File

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

View File

@ -65,7 +65,7 @@ public:
private:
void finish();
// 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_char_bbox(GfxState * state, double * bbox, int inTransparencyGroup);
// 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 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,
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)
max_key = mapped_code;
Unicode u, *pu=&u;
Unicode u;
Unicode const *pu=&u;
if(info.use_tounicode)
{
int n = ctu ?

View File

@ -12,7 +12,9 @@
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);

View File

@ -74,7 +74,7 @@ void HTMLRenderer::drawString(GfxState * state, const GooString * s)
int uLen;
CharCode code;
Unicode *u = nullptr;
Unicode const *u = nullptr;
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,
double dx, double dy,
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();
if(!font) return;

View File

@ -39,7 +39,7 @@ public:
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);
CharCode code, int nBytes, const Unicode *u, int uLen);
// Start a page.
// 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());
bool finished = false;
// read config file
globalParams = new GlobalParams(!param.poppler_data_dir.empty() ? param.poppler_data_dir.c_str() : NULL);
// read poppler config file
globalParams = std::make_unique<GlobalParams>(
!param.poppler_data_dir.empty() ? param.poppler_data_dir.c_str() : NULL
);
// open PDF file
PDFDoc * doc = nullptr;
try
@ -435,8 +438,11 @@ int main(int argc, char **argv)
cerr << "Document has copy-protection bit set." << endl;
}
param.first_page = 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());
param.first_page =
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);
@ -454,7 +460,7 @@ int main(int argc, char **argv)
// clean up
delete doc;
delete globalParams;
globalParams.reset();
// check for memory leaks
// 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);
}
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)
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 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