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

commit of initial update of pdf2htmlEX to poppler 68

This commit is contained in:
Stephen Gaito 2019-05-06 13:03:24 +01:00
parent 665ddaaa27
commit 356d3f103d
8 changed files with 90 additions and 87 deletions

4
.gitignore vendored
View File

@ -18,3 +18,7 @@ src/pdf2htmlEX-config.h
src/util/css_const.h src/util/css_const.h
test export-ignore test export-ignore
Testing/* Testing/*
DartConfiguration.tcl
test/test.py
*.swp

View File

@ -17,7 +17,7 @@
// Copyright (C) 2005-2007 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2005-2007 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org>
// Copyright (C) 2005, 2009, 2012, 2013, 2015, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005, 2009, 2012, 2013, 2015, 2017, 2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006, 2007, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2006, 2007, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2007 Koji Otani <sho@bbr.jp> // Copyright (C) 2007 Koji Otani <sho@bbr.jp>
// Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk> // Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk>
@ -69,17 +69,17 @@
// CairoFont // CairoFont
//------------------------------------------------------------------------ //------------------------------------------------------------------------
CairoFont::CairoFont(Ref ref, CairoFont::CairoFont(Ref refA,
cairo_font_face_t *cairo_font_face, cairo_font_face_t *cairo_font_faceA,
int *codeToGID, int *codeToGIDA,
Guint codeToGIDLen, Guint codeToGIDLenA,
GBool substitute, GBool substituteA,
GBool printing) : ref(ref), GBool printingA) : ref(refA),
cairo_font_face(cairo_font_face), cairo_font_face(cairo_font_faceA),
codeToGID(codeToGID), codeToGID(codeToGIDA),
codeToGIDLen(codeToGIDLen), codeToGIDLen(codeToGIDLenA),
substitute(substitute), substitute(substituteA),
printing(printing) { } printing(printingA) { }
CairoFont::~CairoFont() { CairoFont::~CairoFont() {
cairo_font_face_destroy (cairo_font_face); cairo_font_face_destroy (cairo_font_face);
@ -378,22 +378,21 @@ _ft_new_face (FT_Library lib,
#define _ft_new_face _ft_new_face_uncached #define _ft_new_face _ft_new_face_uncached
#endif #endif
CairoFreeTypeFont::CairoFreeTypeFont(Ref ref, CairoFreeTypeFont::CairoFreeTypeFont(Ref refA,
cairo_font_face_t *cairo_font_face, cairo_font_face_t *cairo_font_faceA,
int *codeToGID, int *codeToGIDA,
Guint codeToGIDLen, Guint codeToGIDLenA,
GBool substitute) : CairoFont(ref, GBool substituteA) : CairoFont(refA,
cairo_font_face, cairo_font_faceA,
codeToGID, codeToGIDA,
codeToGIDLen, codeToGIDLenA,
substitute, substituteA,
gTrue) { } gTrue) { }
CairoFreeTypeFont::~CairoFreeTypeFont() { } CairoFreeTypeFont::~CairoFreeTypeFont() { }
CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
FT_Library lib, GBool useCIDs) { FT_Library lib, GBool useCIDs) {
Object refObj, strObj;
GooString *fileName; GooString *fileName;
char *fileNameC; char *fileNameC;
char *font_data; char *font_data;
@ -735,7 +734,6 @@ _render_type3_glyph (cairo_scaled_font_t *scaled_font,
CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, PDFDoc *doc, CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, PDFDoc *doc,
CairoFontEngine *fontEngine, CairoFontEngine *fontEngine,
GBool printing, XRef *xref) { GBool printing, XRef *xref) {
Object refObj, strObj;
type3_font_info_t *info; type3_font_info_t *info;
cairo_font_face_t *font_face; cairo_font_face_t *font_face;
Ref ref; Ref ref;
@ -778,18 +776,18 @@ CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, PDFDoc *doc,
return new CairoType3Font(ref, doc, font_face, codeToGID, codeToGIDLen, printing, xref); return new CairoType3Font(ref, doc, font_face, codeToGID, codeToGIDLen, printing, xref);
} }
CairoType3Font::CairoType3Font(Ref ref, CairoType3Font::CairoType3Font(Ref refA,
PDFDoc *doc, PDFDoc *docA,
cairo_font_face_t *cairo_font_face, cairo_font_face_t *cairo_font_faceA,
int *codeToGID, int *codeToGIDA,
Guint codeToGIDLen, Guint codeToGIDLenA,
GBool printing, XRef *xref) : CairoFont(ref, GBool printingA, XRef *xref) : CairoFont(refA,
cairo_font_face, cairo_font_faceA,
codeToGID, codeToGIDA,
codeToGIDLen, codeToGIDLenA,
gFalse, gFalse,
printing), printingA),
doc(doc) { } doc(docA) { }
CairoType3Font::~CairoType3Font() { } CairoType3Font::~CairoType3Font() { }

View File

@ -16,9 +16,9 @@
// //
// Copyright (C) 2005-2008 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2005-2008 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005, 2009, 2012, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005, 2009, 2012, 2017, 2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru> // Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
// Copyright (C) 2006-2011, 2013, 2014, 2017 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2006-2011, 2013, 2014, 2017, 2018 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2008 Carl Worth <cworth@cworth.org> // Copyright (C) 2008 Carl Worth <cworth@cworth.org>
// Copyright (C) 2008-2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2008-2017 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu> // Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
@ -29,6 +29,7 @@
// Copyright (C) 2012 Patrick Pfeifer <p2000@mailinator.com> // Copyright (C) 2012 Patrick Pfeifer <p2000@mailinator.com>
// Copyright (C) 2012, 2015, 2016 Jason Crain <jason@aquaticape.us> // Copyright (C) 2012, 2015, 2016 Jason Crain <jason@aquaticape.us>
// Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> // Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
// //
// To see a description of the changes please see the Changelog file that // To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git // came with your tarball or type make ChangeLog if you are building from git
@ -959,7 +960,7 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat
adjusted_stroke_width_tmp = adjusted_stroke_width; adjusted_stroke_width_tmp = adjusted_stroke_width;
maskTmp = mask; maskTmp = mask;
mask = nullptr; mask = nullptr;
gfx = new Gfx(doc, this, resDict, &box, nullptr, nullptr, nullptr, gfxA->getXRef()); gfx = new Gfx(doc, this, resDict, &box, nullptr, nullptr, nullptr, gfxA);
if (paintType == 2) if (paintType == 2)
inUncoloredPattern = gTrue; inUncoloredPattern = gTrue;
gfx->display(str); gfx->display(str);
@ -1379,7 +1380,7 @@ void CairoOutputDev::fillToStrokePathClip(GfxState *state) {
cairo_restore (cairo); cairo_restore (cairo);
} }
void CairoOutputDev::beginString(GfxState *state, GooString *s) void CairoOutputDev::beginString(GfxState *state, const GooString *s)
{ {
int len = s->getLength(); int len = s->getLength();
@ -1588,7 +1589,7 @@ void CairoOutputDev::endTextObject(GfxState *state) {
} }
} }
void CairoOutputDev::beginActualText(GfxState *state, GooString *text) void CairoOutputDev::beginActualText(GfxState *state, const GooString *text)
{ {
if (this->text) if (this->text)
actualText->begin(state, text); actualText->begin(state, text);
@ -1970,7 +1971,7 @@ CairoOutputDev::getFilterForSurface(cairo_surface_t *image,
GBool interpolate) GBool interpolate)
{ {
if (interpolate) if (interpolate)
return CAIRO_FILTER_BEST; return CAIRO_FILTER_GOOD;
int orig_width = cairo_image_surface_get_width (image); int orig_width = cairo_image_surface_get_width (image);
int orig_height = cairo_image_surface_get_height (image); int orig_height = cairo_image_surface_get_height (image);
@ -1990,7 +1991,7 @@ CairoOutputDev::getFilterForSurface(cairo_surface_t *image,
if (scaled_width / orig_width >= 4 || scaled_height / orig_height >= 4) if (scaled_width / orig_width >= 4 || scaled_height / orig_height >= 4)
return CAIRO_FILTER_NEAREST; return CAIRO_FILTER_NEAREST;
return CAIRO_FILTER_BEST; return CAIRO_FILTER_GOOD;
} }
void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
@ -2458,7 +2459,7 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream
* cairo doesn't yet do minifaction filtering causing scaled down * cairo doesn't yet do minifaction filtering causing scaled down
* images with CAIRO_FILTER_NEAREST to look really bad */ * images with CAIRO_FILTER_NEAREST to look really bad */
cairo_pattern_set_filter (pattern, cairo_pattern_set_filter (pattern,
interpolate ? CAIRO_FILTER_BEST : CAIRO_FILTER_FAST); interpolate ? CAIRO_FILTER_GOOD : CAIRO_FILTER_FAST);
if (state->getFillColorSpace()->getMode() == csPattern) { if (state->getFillColorSpace()->getMode() == csPattern) {
cairo_matrix_init_translate (&matrix, 0, scaledHeight); cairo_matrix_init_translate (&matrix, 0, scaledHeight);
@ -3193,7 +3194,6 @@ public:
} }
void getRow(int row_num, uint32_t *row_data) override { void getRow(int row_num, uint32_t *row_data) override {
int i;
Guchar *pix; Guchar *pix;
if (row_num <= current_row) if (row_num <= current_row)
@ -3214,7 +3214,7 @@ public:
Guchar *p = pix; Guchar *p = pix;
GfxRGB rgb; GfxRGB rgb;
for (i = 0; i < width; i++) { for (int i = 0; i < width; i++) {
rgb = lookup[*p]; rgb = lookup[*p];
row_data[i] = row_data[i] =
((int) colToByte(rgb.r) << 16) | ((int) colToByte(rgb.r) << 16) |
@ -3259,7 +3259,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
cairo_matrix_t matrix; cairo_matrix_t matrix;
int width, height; int width, height;
int scaledWidth, scaledHeight; int scaledWidth, scaledHeight;
cairo_filter_t filter = CAIRO_FILTER_BEST; cairo_filter_t filter = CAIRO_FILTER_GOOD;
RescaleDrawImage rescale; RescaleDrawImage rescale;
LOG (printf ("drawImage %dx%d\n", widthA, heightA)); LOG (printf ("drawImage %dx%d\n", widthA, heightA));

View File

@ -18,12 +18,13 @@
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru> // Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
// Copyright (C) 2006-2011, 2013 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2006-2011, 2013 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2008, 2009, 2011-2016 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2008, 2009, 2011-2017 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu> // Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
// Copyright (C) 2010-2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2010-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> // Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
// Copyright (C) 2016 Jason Crain <jason@aquaticape.us> // Copyright (C) 2016 Jason Crain <jason@aquaticape.us>
// Copyright (C) 2018 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
// //
// To see a description of the changes please see the Changelog file that // To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git // came with your tarball or type make ChangeLog if you are building from git
@ -191,13 +192,13 @@ public:
void eoClip(GfxState *state) override; void eoClip(GfxState *state) override;
//----- text drawing //----- text drawing
void beginString(GfxState *state, GooString *s) override; void beginString(GfxState *state, const GooString *s) override;
void endString(GfxState *state) override; void endString(GfxState *state) override;
void drawChar(GfxState *state, double x, double y, 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) override; CharCode code, int nBytes, Unicode *u, int uLen) override;
void beginActualText(GfxState *state, GooString *text) override; void beginActualText(GfxState *state, const GooString *text) override;
void endActualText(GfxState *state) override; void endActualText(GfxState *state) override;
GBool beginType3Char(GfxState *state, double x, double y, GBool beginType3Char(GfxState *state, double x, double y,
@ -269,10 +270,10 @@ public:
void setCairo (cairo_t *cr); void setCairo (cairo_t *cr);
void setTextPage (TextPage *text); void setTextPage (TextPage *text);
void setPrinting (GBool printing) { this->printing = printing; needFontUpdate = gTrue; } void setPrinting (GBool printingA) { printing = printingA; needFontUpdate = gTrue; }
void setAntialias(cairo_antialias_t antialias); void setAntialias(cairo_antialias_t antialias);
void setInType3Char(GBool inType3Char) { this->inType3Char = inType3Char; } void setInType3Char(GBool inType3CharA) { inType3Char = inType3CharA; }
void getType3GlyphWidth (double *wx, double *wy) { *wx = t3_glyph_wx; *wy = t3_glyph_wy; } void getType3GlyphWidth (double *wx, double *wy) { *wx = t3_glyph_wx; *wy = t3_glyph_wy; }
GBool hasType3GlyphBBox () { return t3_glyph_has_bbox; } GBool hasType3GlyphBBox () { return t3_glyph_has_bbox; }
double *getType3GlyphBBox () { return t3_glyph_bbox; } double *getType3GlyphBBox () { return t3_glyph_bbox; }
@ -335,7 +336,6 @@ protected:
GBool printing; GBool printing;
GBool use_show_text_glyphs; GBool use_show_text_glyphs;
GBool text_matrix_valid; GBool text_matrix_valid;
cairo_surface_t *surface;
cairo_glyph_t *glyphs; cairo_glyph_t *glyphs;
int glyphCount; int glyphCount;
cairo_text_cluster_t *clusters; cairo_text_cluster_t *clusters;
@ -359,7 +359,6 @@ protected:
cairo_pattern_t *shape; cairo_pattern_t *shape;
cairo_pattern_t *mask; cairo_pattern_t *mask;
cairo_matrix_t mask_matrix; cairo_matrix_t mask_matrix;
cairo_surface_t *cairo_shape_surface;
cairo_t *cairo_shape; cairo_t *cairo_shape;
int knockoutCount; int knockoutCount;
struct ColorSpaceStack { struct ColorSpaceStack {

View File

@ -170,7 +170,7 @@ protected:
void post_process(void); void post_process(void);
void process_outline(void); void process_outline(void);
void process_outline_items(GooList * items); void process_outline_items(const GooList * items);
void process_form(std::ofstream & out); void process_form(std::ofstream & out);
@ -179,7 +179,7 @@ protected:
void dump_css(void); void dump_css(void);
// convert a LinkAction to a string that our Javascript code can understand // convert a LinkAction to a string that our Javascript code can understand
std::string get_linkaction_str(LinkAction *, std::string & detail); std::string get_linkaction_str(const LinkAction *, std::string & detail);
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
/* /*

View File

@ -634,7 +634,9 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
Unicode u, *pu=&u; Unicode u, *pu=&u;
if(info.use_tounicode) if(info.use_tounicode)
{ {
int n = ctu ? (ctu->mapToUnicode(cur_code, &pu)) : 0; int n = ctu ?
(((CharCodeToUnicode *)ctu)->mapToUnicode(cur_code, &pu)) :
0;
u = check_unicode(pu, n, cur_code, font); u = check_unicode(pu, n, cur_code, font);
} }
else else
@ -756,7 +758,7 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
} }
if(ctu) if(ctu)
ctu->decRefCnt(); ((CharCodeToUnicode *)ctu)->decRefCnt();
} }
/* /*

View File

@ -126,7 +126,7 @@ static string get_linkdest_detail_str(LinkDest * dest, Catalog * catalog, int &
return sout.str(); return sout.str();
} }
string HTMLRenderer::get_linkaction_str(LinkAction * action, string & detail) string HTMLRenderer::get_linkaction_str(const LinkAction * action, string & detail)
{ {
string dest_str; string dest_str;
detail = ""; detail = "";
@ -137,7 +137,7 @@ string HTMLRenderer::get_linkaction_str(LinkAction * action, string & detail)
{ {
case actionGoTo: case actionGoTo:
{ {
auto * real_action = dynamic_cast<LinkGoTo*>(action); auto * real_action = dynamic_cast<const LinkGoTo*>(action);
LinkDest * dest = nullptr; LinkDest * dest = nullptr;
if(auto _ = real_action->getDest()) if(auto _ = real_action->getDest())
dest = _->copy(); dest = _->copy();
@ -162,7 +162,7 @@ string HTMLRenderer::get_linkaction_str(LinkAction * action, string & detail)
break; break;
case actionURI: case actionURI:
{ {
auto * real_action = dynamic_cast<LinkURI*>(action); auto * real_action = dynamic_cast<const LinkURI*>(action);
assert(real_action != nullptr); assert(real_action != nullptr);
dest_str = real_action->getURI()->getCString(); dest_str = real_action->getURI()->getCString();
} }

View File

@ -21,7 +21,7 @@ namespace pdf2htmlEX {
using std::ostream; using std::ostream;
void HTMLRenderer::process_outline_items(GooList * items) void HTMLRenderer::process_outline_items(const GooList * items)
{ {
if((!items) || (items->getLength() == 0)) if((!items) || (items->getLength() == 0))
return; return;