From c898421d589270a367ea3b42f9b64b71abfb9654 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Fri, 5 Jun 2026 22:35:57 +0200 Subject: [PATCH 1/6] use override --- pdf2htmlEX/src/ArgParser.h | 4 +- .../CairoBackgroundRenderer.h | 16 ++-- .../SplashBackgroundRenderer.h | 16 ++-- pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h | 86 +++++++++---------- pdf2htmlEX/src/HTMLRenderer/text.cc | 2 +- pdf2htmlEX/src/Preprocessor.h | 20 ++--- 6 files changed, 71 insertions(+), 73 deletions(-) diff --git a/pdf2htmlEX/src/ArgParser.h b/pdf2htmlEX/src/ArgParser.h index c0f8cdea..6080b917 100644 --- a/pdf2htmlEX/src/ArgParser.h +++ b/pdf2htmlEX/src/ArgParser.h @@ -96,8 +96,8 @@ class ArgParser T * location, const Tv & default_value, const char * description, bool dont_show_default); - virtual void parse (const char * arg) const; - virtual void show_usage (std::ostream & out) const; + void parse (const char * arg) const override; + void show_usage (std::ostream & out) const override; private: T * location; diff --git a/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.h b/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.h index f8bbc07b..832deae5 100644 --- a/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.h +++ b/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.h @@ -29,20 +29,20 @@ class CairoBackgroundRenderer : public BackgroundRenderer, CairoOutputDev public: CairoBackgroundRenderer(HTMLRenderer * html_renderer, const Param & param); - virtual ~CairoBackgroundRenderer(); + ~CairoBackgroundRenderer() override; - virtual void init(PDFDoc * doc); - virtual bool render_page(PDFDoc * doc, int pageno); - virtual void embed_image(int pageno); + void init(PDFDoc * doc) override; + bool render_page(PDFDoc * doc, int pageno) override; + void embed_image(int pageno) override; // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual bool interpretType3Chars() { return !param.process_type3; } + bool interpretType3Chars() override { return !param.process_type3; } - virtual void drawChar(GfxState *state, double x, double y, + void drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, - CharCode code, int nBytes, const Unicode *u, int uLen); + CharCode code, int nBytes, const Unicode *u, int uLen) override; //for proof void beginTextObject(GfxState *state); @@ -51,7 +51,7 @@ class CairoBackgroundRenderer : public BackgroundRenderer, CairoOutputDev void updateRender(GfxState *state); protected: - virtual void setMimeData(GfxState *state, Stream *str, Object *ref, GfxImageColorMap *colorMap, cairo_surface_t *image); + void setMimeData(GfxState *state, Stream *str, Object *ref, GfxImageColorMap *colorMap, cairo_surface_t *image) override; protected: HTMLRenderer * html_renderer; diff --git a/pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.h b/pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.h index d2138c1a..e0fe5eeb 100644 --- a/pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.h +++ b/pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.h @@ -29,22 +29,20 @@ class SplashBackgroundRenderer : public BackgroundRenderer, SplashOutputDev //format: "png" or "jpg", or "" for a default format SplashBackgroundRenderer(const std::string & format, HTMLRenderer * html_renderer, const Param & param); - virtual ~SplashBackgroundRenderer() { } - - virtual void init(PDFDoc * doc); - virtual bool render_page(PDFDoc * doc, int pageno); - virtual void embed_image(int pageno); + void init(PDFDoc * doc) override; + bool render_page(PDFDoc * doc, int pageno) override; + void embed_image(int pageno) override; // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual bool interpretType3Chars() { return !param.process_type3; } + bool interpretType3Chars() override { return !param.process_type3; } - virtual void startPage(int pageNum, GfxState *state, XRef *xrefA); + void startPage(int pageNum, GfxState *state, XRef *xrefA) override; - virtual void drawChar(GfxState *state, double x, double y, + void drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, - CharCode code, int nBytes, const Unicode *u, int uLen); + CharCode code, int nBytes, const Unicode *u, int uLen) override; //for proof void beginTextObject(GfxState *state); diff --git a/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h b/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h index 983962d1..85c49816 100644 --- a/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h +++ b/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h @@ -76,7 +76,7 @@ namespace pdf2htmlEX { struct HTMLRenderer : OutputDev { HTMLRenderer(const char* progPath, Param & param); - virtual ~HTMLRenderer(); + ~HTMLRenderer() override; void process(PDFDoc * doc); @@ -88,102 +88,102 @@ struct HTMLRenderer : OutputDev // Does this device use upside-down coordinates? // (Upside-down means (0,0) is the top left corner of the page.) - virtual bool upsideDown() { return false; } + bool upsideDown() override { return false; } // Does this device use drawChar() or drawString()? - virtual bool useDrawChar() { return false; } + bool useDrawChar() override { return false; } // Does this device use functionShadedFill(), axialShadedFill(), and // radialShadedFill()? If this returns false, these shaded fills // will be reduced to a series of other drawing operations. - virtual bool useShadedFills(int type) { return (type == 2) ? true: false; } + bool useShadedFills(int type) override { return (type == 2) ? true: false; } // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual bool interpretType3Chars() { return false; } + bool interpretType3Chars() override { return false; } // Does this device need non-text content? - virtual bool needNonText() { return (param.process_nontext) ? true: false; } + bool needNonText() override { return (param.process_nontext) ? true: false; } // Does this device need to clip pages to the crop box even when the // box is the crop box? - virtual bool needClipToCropBox() { return true; } + bool needClipToCropBox() override { return true; } - virtual void setDefaultCTM(const double *ctm); + void setDefaultCTM(const double *ctm) override; // Start a page. - virtual void startPage(int pageNum, GfxState *state, XRef * xref); + void startPage(int pageNum, GfxState *state, XRef * xref) override; // End a page. - virtual void endPage(); + void endPage() override; /* * To optimize false alarms * We just mark as changed, and recheck if they have been changed when we are about to output a new string */ - virtual void restoreState(GfxState * state); + void restoreState(GfxState * state) override; - virtual void saveState(GfxState *state); + void saveState(GfxState *state) override; - virtual void updateAll(GfxState * state); + void updateAll(GfxState * state) override; - virtual void updateRise(GfxState * state); - virtual void updateTextPos(GfxState * state); - virtual void updateTextShift(GfxState * state, double shift); + void updateRise(GfxState * state) override; + void updateTextPos(GfxState * state) override; + void updateTextShift(GfxState * state, double shift) override; - virtual void updateFont(GfxState * state); - virtual void updateCTM(GfxState * state, double m11, double m12, double m21, double m22, double m31, double m32); - virtual void updateTextMat(GfxState * state); - virtual void updateHorizScaling(GfxState * state); + void updateFont(GfxState * state) override; + void updateCTM(GfxState * state, double m11, double m12, double m21, double m22, double m31, double m32) override; + void updateTextMat(GfxState * state) override; + void updateHorizScaling(GfxState * state) override; - virtual void updateCharSpace(GfxState * state); - virtual void updateWordSpace(GfxState * state); + void updateCharSpace(GfxState * state) override; + void updateWordSpace(GfxState * state) override; - virtual void updateRender(GfxState * state); + void updateRender(GfxState * state) override; - virtual void updateFillColorSpace(GfxState * state); - virtual void updateStrokeColorSpace(GfxState * state); - virtual void updateFillColor(GfxState * state); - virtual void updateStrokeColor(GfxState * state); + void updateFillColorSpace(GfxState * state) override; + void updateStrokeColorSpace(GfxState * state) override; + void updateFillColor(GfxState * state) override; + void updateStrokeColor(GfxState * state) override; /* * Rendering */ - virtual void clip(GfxState * state); - virtual void eoClip(GfxState * state); - virtual void clipToStrokePath(GfxState * state); + void clip(GfxState * state) override; + void eoClip(GfxState * state) override; + void clipToStrokePath(GfxState * state) override; - virtual void drawString(GfxState * state, const GooString * s); + void drawString(GfxState * state, const GooString * s) override; - virtual void drawImage(GfxState * state, Object * ref, Stream * str, + void drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, - bool interpolate, const int *maskColors, bool inlineImg); + bool interpolate, const int *maskColors, bool inlineImg) override; - virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, + void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap, - bool maskInterpolate); + bool maskInterpolate) override; - virtual void stroke(GfxState *state); - virtual void fill(GfxState *state); - virtual void eoFill(GfxState *state); - virtual bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax); + void stroke(GfxState *state) override; + void fill(GfxState *state) override; + void eoFill(GfxState *state) override; + bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override; - virtual void beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/, + void beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, bool /*isolated*/, bool /*knockout*/, - bool /*forSoftMask*/); - virtual void endTransparencyGroup(GfxState * /*state*/); + bool /*forSoftMask*/) override; + void endTransparencyGroup(GfxState * /*state*/) override; - virtual void processLink(AnnotLink * al); + void processLink(AnnotLink * al) override; /* * Covered text handling. diff --git a/pdf2htmlEX/src/HTMLRenderer/text.cc b/pdf2htmlEX/src/HTMLRenderer/text.cc index 01bd032d..25404762 100644 --- a/pdf2htmlEX/src/HTMLRenderer/text.cc +++ b/pdf2htmlEX/src/HTMLRenderer/text.cc @@ -188,7 +188,7 @@ void HTMLRenderer::drawString(GfxState * state, const GooString * s) bool HTMLRenderer::is_char_covered(int index) { - auto covered = covered_text_detector.get_chars_covered(); + const auto& covered = covered_text_detector.get_chars_covered(); if (index < 0 || index >= (int)covered.size()) { std::cerr << "Warning: HTMLRenderer::is_char_covered: index out of bound: " diff --git a/pdf2htmlEX/src/Preprocessor.h b/pdf2htmlEX/src/Preprocessor.h index 756993d8..a31a6989 100644 --- a/pdf2htmlEX/src/Preprocessor.h +++ b/pdf2htmlEX/src/Preprocessor.h @@ -26,25 +26,25 @@ namespace pdf2htmlEX { class Preprocessor : public OutputDev { public: Preprocessor(const Param & param); - virtual ~Preprocessor(void); + ~Preprocessor(void) override; void process(PDFDoc * doc); - virtual bool upsideDown() { return false; } - virtual bool useDrawChar() { return true; } - virtual bool interpretType3Chars() { return false; } - virtual bool needNonText() { return false; } - virtual bool needClipToCropBox() { return true; } + bool upsideDown() override { return false; } + bool useDrawChar() override { return true; } + bool interpretType3Chars() override { return false; } + bool needNonText() override { return false; } + bool needClipToCropBox() override { return true; } - virtual void drawChar(GfxState *state, double x, double y, + void drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, - CharCode code, int nBytes, const Unicode *u, int uLen); + CharCode code, int nBytes, const Unicode *u, int uLen) override; // Start a page. // UGLY: These 2 versions are for different versions of poppler - virtual void startPage(int pageNum, GfxState *state); - virtual void startPage(int pageNum, GfxState *state, XRef * xref); + void startPage(int pageNum, GfxState *state) override; + void startPage(int pageNum, GfxState *state, XRef * xref) override; const char * get_code_map (long long font_id) const; double get_max_width (void) const { return max_width; } From 151787eb3728779a661d177d42b6dcb376e8c2f0 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Fri, 5 Jun 2026 22:41:16 +0200 Subject: [PATCH 2/6] update drawString --- pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h | 2 +- pdf2htmlEX/src/HTMLRenderer/text.cc | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h b/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h index 85c49816..4dce1540 100644 --- a/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h +++ b/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h @@ -156,7 +156,7 @@ struct HTMLRenderer : OutputDev void eoClip(GfxState * state) override; void clipToStrokePath(GfxState * state) override; - void drawString(GfxState * state, const GooString * s) override; + void drawString(GfxState * state, const std::string& s) override; void drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, diff --git a/pdf2htmlEX/src/HTMLRenderer/text.cc b/pdf2htmlEX/src/HTMLRenderer/text.cc index 25404762..22fbb87b 100644 --- a/pdf2htmlEX/src/HTMLRenderer/text.cc +++ b/pdf2htmlEX/src/HTMLRenderer/text.cc @@ -23,9 +23,9 @@ using std::none_of; using std::cerr; using std::endl; -void HTMLRenderer::drawString(GfxState * state, const GooString * s) +void HTMLRenderer::drawString(GfxState * state, const std::string& s) { - if(s->empty()) + if(s.empty()) return; auto font = state->getFont(); @@ -58,8 +58,8 @@ void HTMLRenderer::drawString(GfxState * state, const GooString * s) // Now ready to output // get the unicodes - const char *p = s->c_str(); - int len = s->size(); + const char *p = s.c_str(); + int len = s.size(); //accumulated displacement of chars in this string, in text object space double dx = 0; From 7452d176366680ffe936c64fe7ab674e5c5edf79 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Fri, 5 Jun 2026 22:48:17 +0200 Subject: [PATCH 3/6] update signatures --- pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h | 4 ++-- pdf2htmlEX/src/HTMLRenderer/draw.cc | 2 +- pdf2htmlEX/src/HTMLRenderer/general.cc | 4 ++-- pdf2htmlEX/src/Preprocessor.cc | 7 +------ pdf2htmlEX/src/Preprocessor.h | 1 - 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h b/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h index 4dce1540..1abe7e1d 100644 --- a/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h +++ b/pdf2htmlEX/src/HTMLRenderer/HTMLRenderer.h @@ -109,7 +109,7 @@ struct HTMLRenderer : OutputDev // box is the crop box? bool needClipToCropBox() override { return true; } - void setDefaultCTM(const double *ctm) override; + void setDefaultCTM(const std::array &ctm) override; // Start a page. void startPage(int pageNum, GfxState *state, XRef * xref) override; @@ -176,7 +176,7 @@ struct HTMLRenderer : OutputDev void eoFill(GfxState *state) override; bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override; - void beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/, + void beginTransparencyGroup(GfxState * /*state*/, const std::array & /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, bool /*isolated*/, bool /*knockout*/, bool /*forSoftMask*/) override; diff --git a/pdf2htmlEX/src/HTMLRenderer/draw.cc b/pdf2htmlEX/src/HTMLRenderer/draw.cc index 39cfa9ca..2e0d2f34 100644 --- a/pdf2htmlEX/src/HTMLRenderer/draw.cc +++ b/pdf2htmlEX/src/HTMLRenderer/draw.cc @@ -62,7 +62,7 @@ bool HTMLRenderer::axialShadedFill(GfxState *state, GfxAxialShading *shading, do return true; } -void HTMLRenderer::beginTransparencyGroup(GfxState *state, const double *bbox, +void HTMLRenderer::beginTransparencyGroup(GfxState *state, const std::array &bbox, GfxColorSpace *blendingColorSpace, bool isolated, bool knockout, bool forSoftMask) { diff --git a/pdf2htmlEX/src/HTMLRenderer/general.cc b/pdf2htmlEX/src/HTMLRenderer/general.cc index c9a34f8c..3d686232 100644 --- a/pdf2htmlEX/src/HTMLRenderer/general.cc +++ b/pdf2htmlEX/src/HTMLRenderer/general.cc @@ -221,9 +221,9 @@ bool HTMLRenderer::renderPage(PDFDoc *doc, int pageno) return false; } -void HTMLRenderer::setDefaultCTM(const double *ctm) +void HTMLRenderer::setDefaultCTM(const std::array &ctm) { - memcpy(default_ctm, ctm, sizeof(default_ctm)); + memcpy(default_ctm, ctm.data(), sizeof(default_ctm)); } void HTMLRenderer::startPage(int pageNum, GfxState *state, XRef * xref) diff --git a/pdf2htmlEX/src/Preprocessor.cc b/pdf2htmlEX/src/Preprocessor.cc index e1ca5e12..f6011d15 100644 --- a/pdf2htmlEX/src/Preprocessor.cc +++ b/pdf2htmlEX/src/Preprocessor.cc @@ -89,12 +89,7 @@ void Preprocessor::drawChar(GfxState *state, double x, double y, cur_code_map[code] = 1; } -void Preprocessor::startPage(int pageNum, GfxState *state) -{ - startPage(pageNum, state, nullptr); -} - -void Preprocessor::startPage(int pageNum, GfxState *state, XRef * xref) +void Preprocessor::startPage(int pageNum, GfxState *state, XRef *xref) { max_width = max(max_width, state->getPageWidth()); max_height = max(max_height, state->getPageHeight()); diff --git a/pdf2htmlEX/src/Preprocessor.h b/pdf2htmlEX/src/Preprocessor.h index a31a6989..df97617a 100644 --- a/pdf2htmlEX/src/Preprocessor.h +++ b/pdf2htmlEX/src/Preprocessor.h @@ -43,7 +43,6 @@ class Preprocessor : public OutputDev { // Start a page. // UGLY: These 2 versions are for different versions of poppler - void startPage(int pageNum, GfxState *state) override; void startPage(int pageNum, GfxState *state, XRef * xref) override; const char * get_code_map (long long font_id) const; From b4aa9f07308dc6583d5872a80aa694d3da57d644 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Fri, 5 Jun 2026 22:58:18 +0200 Subject: [PATCH 4/6] more --- .../src/BackgroundRenderer/CairoBackgroundRenderer.cc | 8 ++++---- .../src/BackgroundRenderer/CairoBackgroundRenderer.h | 4 ++-- .../BackgroundRenderer/SplashBackgroundRenderer.cc | 4 ++-- .../src/BackgroundRenderer/SplashBackgroundRenderer.h | 2 +- pdf2htmlEX/src/pdf2htmlEX.cc | 11 +++++------ 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.cc b/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.cc index e567994c..938b9063 100644 --- a/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.cc +++ b/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.cc @@ -81,11 +81,11 @@ void CairoBackgroundRenderer::beginTextObject(GfxState *state) CairoOutputDev::beginTextObject(state); } -void CairoBackgroundRenderer::beginString(GfxState *state, const GooString * str) +void CairoBackgroundRenderer::beginString(GfxState *state, const std::string & str) { if (param.proof == 2) proof_begin_string(state, this); - CairoOutputDev::beginString(state, str->toStr()); + CairoOutputDev::beginString(state, str); } void CairoBackgroundRenderer::endTextObject(GfxState *state) @@ -235,11 +235,11 @@ string CairoBackgroundRenderer::build_bitmap_path(int id) return string(html_renderer->str_fmt("%s/o%d.jpg", param.dest_dir.c_str(), id)); } // Override CairoOutputDev::setMimeData() and dump bitmaps in SVG to external files. -void CairoBackgroundRenderer::setMimeData(GfxState *state, Stream *str, Object *ref, GfxImageColorMap *colorMap, cairo_surface_t *image) +void CairoBackgroundRenderer::setMimeData(GfxState *state, Stream *str, Object *ref, GfxImageColorMap *colorMap, cairo_surface_t *image, int height) { if (param.svg_embed_bitmap) { - CairoOutputDev::setMimeData(state, str, ref, colorMap, image, cairo_image_surface_get_height (image)); + CairoOutputDev::setMimeData(state, str, ref, colorMap, image, height); return; } diff --git a/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.h b/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.h index 832deae5..0c6fd96c 100644 --- a/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.h +++ b/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.h @@ -46,12 +46,12 @@ class CairoBackgroundRenderer : public BackgroundRenderer, CairoOutputDev //for proof void beginTextObject(GfxState *state); - void beginString(GfxState *state, const GooString * str); + void beginString(GfxState *state, const std::string & str); void endTextObject(GfxState *state); void updateRender(GfxState *state); protected: - void setMimeData(GfxState *state, Stream *str, Object *ref, GfxImageColorMap *colorMap, cairo_surface_t *image) override; + void setMimeData(GfxState *state, Stream *str, Object *ref, GfxImageColorMap *colorMap, cairo_surface_t *image, int height) override; protected: HTMLRenderer * html_renderer; diff --git a/pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.cc b/pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.cc index bd0f4d6e..7759e926 100644 --- a/pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.cc +++ b/pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.cc @@ -71,11 +71,11 @@ void SplashBackgroundRenderer::beginTextObject(GfxState *state) SplashOutputDev::beginTextObject(state); } -void SplashBackgroundRenderer::beginString(GfxState *state, const GooString * str) +void SplashBackgroundRenderer::beginString(GfxState *state, const std::string & str) { if (param.proof == 2) proof_begin_string(state, this); - SplashOutputDev::beginString(state, str->toStr()); + SplashOutputDev::beginString(state, str); } void SplashBackgroundRenderer::endTextObject(GfxState *state) diff --git a/pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.h b/pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.h index e0fe5eeb..a6cfa44d 100644 --- a/pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.h +++ b/pdf2htmlEX/src/BackgroundRenderer/SplashBackgroundRenderer.h @@ -46,7 +46,7 @@ class SplashBackgroundRenderer : public BackgroundRenderer, SplashOutputDev //for proof void beginTextObject(GfxState *state); - void beginString(GfxState *state, const GooString * str); + void beginString(GfxState *state, const std::string & str); void endTextObject(GfxState *state); void updateRender(GfxState *state); diff --git a/pdf2htmlEX/src/pdf2htmlEX.cc b/pdf2htmlEX/src/pdf2htmlEX.cc index baa36a02..63ec50fd 100644 --- a/pdf2htmlEX/src/pdf2htmlEX.cc +++ b/pdf2htmlEX/src/pdf2htmlEX.cc @@ -16,7 +16,6 @@ #include #include -#include #include #include @@ -414,17 +413,17 @@ int main(int argc, char **argv) try { - std::optional ownerPW; + std::optional ownerPW; if (!param.owner_password.empty()) { - ownerPW = GooString(param.owner_password); + ownerPW = param.owner_password; } - std::optional userPW; + std::optional userPW; if (!param.user_password.empty()) { - userPW = GooString(param.user_password); + userPW = param.user_password; } - GooString fileName(param.input_filename); + std::string fileName(param.input_filename); // open PDF file std::unique_ptr doc(PDFDocFactory().createPDFDoc(fileName, ownerPW, userPW)); From 3a3442aa7f90a587b870b86d24cad8b22564fcab Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Fri, 5 Jun 2026 23:07:04 +0200 Subject: [PATCH 5/6] remove dead function --- .../CairoBackgroundRenderer.cc | 69 ------------------- .../CairoBackgroundRenderer.h | 3 - 2 files changed, 72 deletions(-) diff --git a/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.cc b/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.cc index 938b9063..01763a47 100644 --- a/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.cc +++ b/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.cc @@ -234,75 +234,6 @@ string CairoBackgroundRenderer::build_bitmap_path(int id) // "o" for "PDF Object" return string(html_renderer->str_fmt("%s/o%d.jpg", param.dest_dir.c_str(), id)); } -// Override CairoOutputDev::setMimeData() and dump bitmaps in SVG to external files. -void CairoBackgroundRenderer::setMimeData(GfxState *state, Stream *str, Object *ref, GfxImageColorMap *colorMap, cairo_surface_t *image, int height) -{ - if (param.svg_embed_bitmap) - { - CairoOutputDev::setMimeData(state, str, ref, colorMap, image, height); - return; - } - - // TODO dump bitmaps in other formats. - if (str->getKind() != strDCT) - return; - - // TODO inline image? - if (ref == nullptr || !ref->isRef()) - return; - - // We only dump rgb or gray jpeg without /Decode array. - // - // Although jpeg support CMYK, PDF readers do color conversion incompatibly with most other - // programs (including browsers): other programs invert CMYK color if 'Adobe' marker (app14) presents - // in a jpeg file; while PDF readers don't, they solely rely on /Decode array to invert color. - // It's a bit complicated to decide whether a CMYK jpeg is safe to dump, so we don't dump at all. - // See also: - // JPEG file embedded in PDF (CMYK) https://forums.adobe.com/thread/975777 - // http://stackoverflow.com/questions/3123574/how-to-convert-from-cmyk-to-rgb-in-java-correctly - // - // In PDF, jpeg stream objects can also specify other color spaces like DeviceN and Separation, - // It is also not safe to dump them directly. - Object obj = str->getDict()->lookup("ColorSpace"); - if (!obj.isName() || (strcmp(obj.getName(), "DeviceRGB") && strcmp(obj.getName(), "DeviceGray")) ) - { - //obj.free(); - return; - } - //obj.free(); - obj = str->getDict()->lookup("Decode"); - if (obj.isArray()) - { - //obj.free(); - return; - } - //obj.free(); - - int imgId = ref->getRef().num; - auto uri = strdup((char*) html_renderer->str_fmt("o%d.jpg", imgId)); - auto st = cairo_surface_set_mime_data(image, CAIRO_MIME_TYPE_URI, - (unsigned char*) uri, strlen(uri), free, uri); - if (st) - { - free(uri); - return; - } - bitmaps_in_current_page.push_back(imgId); - - if(bitmaps_ref_count.find(imgId) != bitmaps_ref_count.end()) - return; - - bitmaps_ref_count[imgId] = 0; - - char *strBuffer; - int len; - if (getStreamData(str->getNextStream(), &strBuffer, &len)) - { - ofstream imgfile(build_bitmap_path(imgId), ofstream::binary); - imgfile.write(strBuffer, len); - free(strBuffer); - } -} } // namespace pdf2htmlEX diff --git a/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.h b/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.h index 0c6fd96c..82d393f1 100644 --- a/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.h +++ b/pdf2htmlEX/src/BackgroundRenderer/CairoBackgroundRenderer.h @@ -50,9 +50,6 @@ class CairoBackgroundRenderer : public BackgroundRenderer, CairoOutputDev void endTextObject(GfxState *state); void updateRender(GfxState *state); -protected: - void setMimeData(GfxState *state, Stream *str, Object *ref, GfxImageColorMap *colorMap, cairo_surface_t *image, int height) override; - protected: HTMLRenderer * html_renderer; const Param & param; From c0c743358c0e054a9e16495d914e6d1921de40e6 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Fri, 5 Jun 2026 23:12:09 +0200 Subject: [PATCH 6/6] revert --- pdf2htmlEX/src/pdf2htmlEX.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pdf2htmlEX/src/pdf2htmlEX.cc b/pdf2htmlEX/src/pdf2htmlEX.cc index 63ec50fd..baa36a02 100644 --- a/pdf2htmlEX/src/pdf2htmlEX.cc +++ b/pdf2htmlEX/src/pdf2htmlEX.cc @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -413,17 +414,17 @@ int main(int argc, char **argv) try { - std::optional ownerPW; + std::optional ownerPW; if (!param.owner_password.empty()) { - ownerPW = param.owner_password; + ownerPW = GooString(param.owner_password); } - std::optional userPW; + std::optional userPW; if (!param.user_password.empty()) { - userPW = param.user_password; + userPW = GooString(param.user_password); } - std::string fileName(param.input_filename); + GooString fileName(param.input_filename); // open PDF file std::unique_ptr doc(PDFDocFactory().createPDFDoc(fileName, ownerPW, userPW));