pdf2djvu: rebuild for poppler-26.06.0

This commit is contained in:
Đoàn Trần Công Danh
2026-06-14 17:11:39 +07:00
parent b2d9476bbc
commit 8374f14a4c
4 changed files with 317 additions and 74 deletions
@@ -0,0 +1,235 @@
--- a/autoconf.hh.in
+++ b/autoconf.hh.in
@@ -62,7 +62,7 @@
#undef PACKAGE_VERSION
/* Define to the version of Poppler, as integer */
-#undef POPPLER_VERSION
+#undef POPPLER_VERSION_INT
/* Define to the version of Poppler */
#undef POPPLER_VERSION_STRING
--- a/configure
+++ b/configure
@@ -5050,7 +5050,7 @@ else $as_nop
fi
-printf "%s\n" "#define POPPLER_VERSION $poppler_version" >>confdefs.h
+printf "%s\n" "#define POPPLER_VERSION_INT $poppler_version" >>confdefs.h
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Poppler xpdf headers" >&5
printf %s "checking for Poppler xpdf headers... " >&6; }
--- a/configure.ac
+++ b/configure.ac
@@ -95,7 +95,7 @@ AS_IF(
[:],
[AC_MSG_ERROR([could not parse Poppler version])]
)
-AC_DEFINE_UNQUOTED([POPPLER_VERSION], [$poppler_version], [Define to the version of Poppler, as integer])
+AC_DEFINE_UNQUOTED([POPPLER_VERSION_INT], [$poppler_version], [Define to the version of Poppler, as integer])
AC_MSG_CHECKING([for Poppler xpdf headers])
original_cppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
--- a/main.cc
+++ b/main.cc
@@ -76,13 +76,13 @@ public:
static int get_page_for_goto_link(pdf::link::GoTo *goto_link, pdf::Catalog *catalog)
{
std::unique_ptr<pdf::link::Destination> dest;
-#if POPPLER_VERSION >= 6400
+#if POPPLER_VERSION_INT >= 6400
const
#endif
pdf::link::Destination *orig_dest = goto_link->getDest();
if (orig_dest == nullptr)
{
-#if POPPLER_VERSION >= 8600
+#if POPPLER_VERSION_INT >= 8600
dest = catalog->findDest(goto_link->getNamedDest());
#else
dest.reset(catalog->findDest(goto_link->getNamedDest()));
@@ -341,7 +341,7 @@ public:
return;
}
-#if POPPLER_VERSION >= 8200
+#if POPPLER_VERSION_INT >= 8200
void drawImage(pdf::gfx::State *state, pdf::Object *object, pdf::Stream *stream, int width, int height,
pdf::gfx::ImageColorMap *color_map, bool interpolate, const int *mask_colors, bool inline_image)
#else
@@ -389,7 +389,7 @@ public:
bool interpretType3Chars() { return false; }
-#if POPPLER_VERSION >= 8200
+#if POPPLER_VERSION_INT >= 8200
void drawChar(pdf::gfx::State *state, double x, double y, double dx, double dy, double origin_x, double origin_y,
CharCode code, int n_bytes, const Unicode *unistr, int length)
#else
@@ -475,7 +475,7 @@ public:
switch (link_action->getKind())
{
case actionURI:
-#if POPPLER_VERSION >= 8600
+#if POPPLER_VERSION_INT >= 8600
uri = dynamic_cast<pdf::link::URI*>(link_action)->getURI();
#else
uri += pdf::get_c_string(dynamic_cast<pdf::link::URI*>(link_action)->getURI());
@@ -519,12 +519,12 @@ public:
// L10N: OCG stands for “Optional Content Group” (see PDF Reference v1.7, §4.10.1)
debug(1) << _("Warning: Unable to convert link with a set-OCG-state action") << std::endl;
return;
-#if POPPLER_VERSION >= 6400
+#if POPPLER_VERSION_INT >= 6400
case actionHide:
debug(1) << _("Warning: Unable to convert link with a hide action") << std::endl;
return;
#endif
-#if POPPLER_VERSION >= 8900
+#if POPPLER_VERSION_INT >= 8900
case actionResetForm:
debug(1) << _("Warning: Unable to convert link with a reset-form action") << std::endl;
return;
@@ -724,7 +724,7 @@ static void pdf_outline_to_djvu_outline(
std::unique_ptr<pdf::link::Action> link_action;
if (!pdf::dict_lookup(current, "Dest", &destination)->isNull())
{
-#if POPPLER_VERSION >= 8600
+#if POPPLER_VERSION_INT >= 8600
link_action = pdf::link::Action::parseDest(&destination);
#else
link_action.reset(pdf::link::Action::parseDest(&destination));
@@ -732,7 +732,7 @@ static void pdf_outline_to_djvu_outline(
}
else if (!pdf::dict_lookup(current, "A", &destination)->isNull())
{
-#if POPPLER_VERSION >= 8600
+#if POPPLER_VERSION_INT >= 8600
link_action = pdf::link::Action::parseAction(&destination);
#else
link_action.reset(pdf::link::Action::parseAction(&destination));
--- a/pdf-backend.cc
+++ b/pdf-backend.cc
@@ -48,7 +48,7 @@
* ======================
*/
-#if POPPLER_VERSION >= 8500
+#if POPPLER_VERSION_INT >= 8500
static void poppler_error_handler(ErrorCategory category, pdf::Offset pos, const char *message)
#else
static void poppler_error_handler(void *data, ErrorCategory category, pdf::Offset pos, const char *message)
@@ -97,7 +97,7 @@ static void poppler_error_handler(void *
error_log << std::endl;
}
-#if POPPLER_VERSION < 7000
+#if POPPLER_VERSION_INT < 7000
static void poppler_error_handler(void *data, ErrorCategory category, pdf::Offset pos, char *message)
{
poppler_error_handler(data, category, pos, const_cast<const char *>(message));
@@ -106,12 +106,12 @@ static void poppler_error_handler(void *
pdf::Environment::Environment()
{
-#if POPPLER_VERSION >= 8300
+#if POPPLER_VERSION_INT >= 8300
globalParams = std::unique_ptr<GlobalParams>(new GlobalParams);
#else
globalParams = new GlobalParams;
#endif
-#if POPPLER_VERSION >= 8500
+#if POPPLER_VERSION_INT >= 8500
setErrorCallback(poppler_error_handler);
#else
setErrorCallback(poppler_error_handler, nullptr);
@@ -129,7 +129,7 @@ void pdf::Environment::set_antialias(boo
*/
pdf::Document::Document(const std::string &file_name)
-#if POPPLER_VERSION >= 220300
+#if POPPLER_VERSION_INT >= 220300
: ::PDFDoc(std::make_unique<pdf::String>(file_name.c_str()))
#else
: ::PDFDoc(new pdf::String(file_name.c_str()))
@@ -232,7 +232,7 @@ void pdf::Document::get_page_size(int n,
const std::string pdf::Document::get_xmp()
{
std::unique_ptr<const pdf::String> mstring;
-#if POPPLER_VERSION >= 211000
+#if POPPLER_VERSION_INT >= 211000
mstring = this->readMetadata();
#else
mstring.reset(this->readMetadata());
@@ -512,13 +512,13 @@ bool pdf::get_glyph(splash::Splash *spla
void pdf::Renderer::convert_path(pdf::gfx::State *state, splash::Path &splash_path)
{
/* Source was copied from <poppler/SplashOutputDev.c>. */
- // for POPPLER_VERSION >= 8300:
+ // for POPPLER_VERSION_INT >= 8300:
// const pdf::gfx::Path *path
auto path = state->getPath();
int n_subpaths = path->getNumSubpaths();
for (int i = 0; i < n_subpaths; i++)
{
- // for POPPLER_VERSION >= 8300:
+ // for POPPLER_VERSION_INT >= 8300:
// const pdf::gfx::Subpath *subpath
auto subpath = path->getSubpath(i);
if (subpath->getNumPoints() > 0)
@@ -627,7 +627,7 @@ namespace pdf
}
}
-#if POPPLER_VERSION >= 7200
+#if POPPLER_VERSION_INT >= 7200
const char * pdf::get_c_string(const pdf::String *str)
{
return str->c_str();
@@ -641,7 +641,7 @@ const char * pdf::get_c_string(const pdf
int pdf::find_page(pdf::Catalog *catalog, pdf::Ref pgref)
{
-#if POPPLER_VERSION >= 7600
+#if POPPLER_VERSION_INT >= 7600
return catalog->findPage(pgref);
#else
return catalog->findPage(pgref.num, pgref.gen);
--- a/pdf-backend.hh
+++ b/pdf-backend.hh
@@ -236,12 +236,12 @@ namespace pdf
this->byte_width = width * 3;
break;
case splashModeXBGR8:
-#if POPPLER_VERSION >= 8100 || defined(SPLASH_CMYK)
+#if POPPLER_VERSION_INT >= 8100 || defined(SPLASH_CMYK)
case splashModeCMYK8:
#endif
this->byte_width = width * 4;
break;
-#if POPPLER_VERSION >= 8100 || defined(SPLASH_CMYK)
+#if POPPLER_VERSION_INT >= 8100 || defined(SPLASH_CMYK)
case splashModeDeviceN8:
#endif
default:
@@ -296,7 +296,7 @@ namespace pdf
const std::string get_xmp();
void get_doc_info(pdf::Object &info)
{
-#if POPPLER_VERSION < 5800
+#if POPPLER_VERSION_INT < 5800
this->getDocInfo(&info);
#else
info = this->getDocInfo();
--- a/pdf-dpi.cc
+++ b/pdf-dpi.cc
@@ -33,7 +33,7 @@ protected:
this->process_image(state, width, height);
}
-#if POPPLER_VERSION >= 8200
+#if POPPLER_VERSION_INT >= 8200
virtual void drawImage(pdf::gfx::State *state, pdf::Object *object, pdf::Stream *stream, int width, int height,
pdf::gfx::ImageColorMap *color_map, bool interpolate, const int *mask_colors, bool inline_image)
#else
+44 -73
View File
@@ -18,7 +18,7 @@
namespace pdf
--- a/pdf-backend.cc
+++ b/pdf-backend.cc
@@ -181,7 +181,7 @@ static bool annotations_callback(pdf::ant::Annotation *annotation, void *user_da
@@ -181,7 +181,7 @@ static bool annotations_callback(pdf::an
border_colors.push_back("");
return true;
}
@@ -27,15 +27,32 @@
switch (color->getSpace())
{
case pdf::ant::Color::colorTransparent:
@@ -499,7 +499,7 @@ bool pdf::get_glyph(splash::Splash *splash, splash::Font *font,
if (font == nullptr)
return false;
splash::ClipResult clip_result;
- if (!font->getGlyph(code, 0, 0, bitmap, static_cast<int>(x), static_cast<int>(y), splash->getClip(), &clip_result))
+ if (!font->getGlyph(code, 0, 0, bitmap, static_cast<int>(x), static_cast<int>(y), const_cast<SplashClip*>(&splash->getClip()), &clip_result))
return false;
return (clip_result != splashClipAllOutside);
}
@@ -407,7 +407,11 @@ pdf::Metadata::Metadata(pdf::Document &d
char tzs = 0; int tzh = 0, tzm = 0;
if (!pdf::dict_lookup(info_dict, field.first, &object)->isString())
continue;
+#if POPPLER_VERSION_INT >= 260400
+ const char *input = object.getString().c_str();
+#else
const char *input = pdf::get_c_string(object.getString());
+#endif
if (input[0] == 'D' && input[1] == ':')
input += 2;
int year = scan_date_digits(input, 4);
@@ -469,8 +473,13 @@ void pdf::set_color(splash::Color &resul
bool pdf::Environment::antialias = false;
+#if POPPLER_VERSION_INT >= 260400
+pdf::Renderer::Renderer(pdf::splash::Color &paper_color, bool monochrome)
+: pdf::splash::OutputDevice(monochrome ? splashModeMono1 : splashModeRGB8, 4, paper_color, true),
+#else
pdf::Renderer::Renderer(pdf::splash::Color &paper_color, bool monochrome)
: pdf::splash::OutputDevice(monochrome ? splashModeMono1 : splashModeRGB8, 4, false, paper_color),
+#endif
catalog(NULL)
{
this->setFontAntialias(pdf::Environment::antialias);
--- a/system.hh
+++ b/system.hh
@@ -223,7 +223,7 @@ namespace encoding
@@ -49,7 +66,7 @@
friend std::ostream &operator << <>(std::ostream &, const proxy<from, to> &);
--- a/pdf-unicode.cc
+++ b/pdf-unicode.cc
@@ -49,7 +49,7 @@ std::string pdf::string_as_utf8(const pdf::String *string)
@@ -49,7 +49,7 @@ std::string pdf::string_as_utf8(const pd
*/
const static uint32_t replacement_character = 0xFFFD;
const char *cstring = pdf::get_c_string(string);
@@ -58,71 +75,11 @@
std::ostringstream stream;
if (clength >= 2 && (cstring[0] & 0xFF) == 0xFE && (cstring[1] & 0xFF) == 0xFF) {
/* UTF-16-BE Byte Order Mark */
--- a/pdf-backend.cc
+++ b/pdf-backend.cc
@@ -499,7 +499,7 @@
if (font == nullptr)
return false;
splash::ClipResult clip_result;
- if (!font->getGlyph(code, 0, 0, bitmap, static_cast<int>(x), static_cast<int>(y), const_cast<SplashClip*>(&splash->getClip()), &clip_result))
+ if (!font->getGlyph(code, 0, 0, bitmap, static_cast<int>(x), static_cast<int>(y), splash->getClip(), &clip_result))
return false;
return (clip_result != splashClipAllOutside);
}
--- a/pdf-backend.cc
+++ b/pdf-backend.cc
@@ -407,7 +407,11 @@ pdf::Metadata::Metadata(pdf::Document &document)
char tzs = 0; int tzh = 0, tzm = 0;
if (!pdf::dict_lookup(info_dict, field.first, &object)->isString())
continue;
+#if POPPLER_VERSION >= 260400
+ const char *input = object.getString().c_str();
+#else
const char *input = pdf::get_c_string(object.getString());
+#endif
if (input[0] == 'D' && input[1] == ':')
input += 2;
int year = scan_date_digits(input, 4);
@@ -470,8 +474,13 @@ void pdf::set_color(splash::Color &result, uint8_t r, uint8_t g, uint8_t b)
*/
bool pdf::Environment::antialias = false;
+#if POPPLER_VERSION >= 260400
+pdf::Renderer::Renderer(pdf::splash::Color &paper_color, bool monochrome)
+: pdf::splash::OutputDevice(monochrome ? splashModeMono1 : splashModeRGB8, 4, paper_color, true),
+#else
pdf::Renderer::Renderer(pdf::splash::Color &paper_color, bool monochrome)
: pdf::splash::OutputDevice(monochrome ? splashModeMono1 : splashModeRGB8, 4, false, paper_color),
+#endif
catalog(NULL)
{
this->setFontAntialias(pdf::Environment::antialias);
--- a/pdf-dpi.cc
+++ b/pdf-dpi.cc
@@ -91,7 +91,11 @@ public:
void DpiGuessDevice::process_image(pdf::gfx::State *state, int width, int height)
{
+#if POPPLER_VERSION >= 260400
+ const double *ctm = state->getCTM().data();
+#else
const double *ctm = state->getCTM();
+#endif
double h_dpi = 72.0 * width / hypot(ctm[0], ctm[1]);
double v_dpi = 72.0 * height / hypot(ctm[2], ctm[3]);
this->min_ = std::min(this->min_, std::min(h_dpi, v_dpi));
--- a/pdf-unicode.cc
+++ b/pdf-unicode.cc
@@ -104,7 +104,12 @@ std::string pdf::string_as_utf8(const pdf::String *string)
@@ -105,7 +105,12 @@ std::string pdf::string_as_utf8(const pd
std::string pdf::string_as_utf8(pdf::Object &object)
{
+#if POPPLER_VERSION >= 260400
+#if POPPLER_VERSION_INT >= 260400
+ pdf::String poppler_str(object.getString().c_str());
+ return pdf::string_as_utf8(&poppler_str);
+#else
@@ -131,3 +88,17 @@
}
/* class pdf::FullNFKC
--- a/pdf-dpi.cc
+++ b/pdf-dpi.cc
@@ -91,7 +91,11 @@ public:
void DpiGuessDevice::process_image(pdf::gfx::State *state, int width, int height)
{
+#if POPPLER_VERSION_INT >= 260400
+ const double *ctm = state->getCTM().data();
+#else
const double *ctm = state->getCTM();
+#endif
double h_dpi = 72.0 * width / hypot(ctm[0], ctm[1]);
double v_dpi = 72.0 * height / hypot(ctm[2], ctm[3]);
this->min_ = std::min(this->min_, std::min(h_dpi, v_dpi));
@@ -0,0 +1,37 @@
--- a/pdf-backend.cc
+++ b/pdf-backend.cc
@@ -163,7 +163,11 @@ static void cmyk_to_rgb(const double cmy
pdf::gfx::RgbColor rgb_cc;
for (int i = 0; i < 4; i++)
cmyk_cc.c[i] = pdf::gfx::double_as_color_component(cmyk[i]);
+#if POPPLER_VERSION_INT >= 260600
+ cmyk_space.getRGB(cmyk_cc, &rgb_cc);
+#else
cmyk_space.getRGB(&cmyk_cc, &rgb_cc);
+#endif
rgb[0] = pdf::gfx::color_component_as_double(rgb_cc.r);
rgb[1] = pdf::gfx::color_component_as_double(rgb_cc.g);
rgb[2] = pdf::gfx::color_component_as_double(rgb_cc.b);
@@ -175,7 +179,7 @@ static bool annotations_callback(pdf::an
std::string border_color;
if (annotation->getType() != pdf::ant::Annotation::typeLink)
return true;
- pdf::ant::Color *color = annotation->getColor();
+ const pdf::ant::Color *color = annotation->getColor();
if (color == nullptr)
{
border_colors.push_back("");
--- a/pdf-backend.hh
+++ b/pdf-backend.hh
@@ -63,7 +63,11 @@ namespace pdf
typedef ::Splash Splash;
typedef ::SplashColor Color;
typedef ::SplashFont Font;
+#if POPPLER_VERSION_INT >= 260500
+ typedef double Coord;
+#else
typedef ::SplashCoord Coord;
+#endif
typedef ::SplashPath Path;
typedef ::SplashGlyphBitmap GlyphBitmap;
typedef ::SplashBitmap Bitmap;
+1 -1
View File
@@ -1,7 +1,7 @@
# Template file for 'pdf2djvu'
pkgname=pdf2djvu
version=0.9.19
revision=12
revision=13
build_style=gnu-configure
hostmakedepends="pkg-config djvulibre gettext"
makedepends="djvulibre-devel poppler-devel libgraphicsmagick-devel exiv2-devel