diff --git a/setup/build_environment.py b/setup/build_environment.py index 82a6421ed5..e7b40449c3 100644 --- a/setup/build_environment.py +++ b/setup/build_environment.py @@ -191,6 +191,9 @@ else: lh = os.path.join(poppler_inc_dirs[0], 'Link.h') if 'class AnnotLink' not in open(lh, 'rb').read(): poppler_cflags.append('-DPOPPLER_OLD_LINK_TYPE') + ph = os.path.join(poppler_inc_dirs[0], 'Page.h') + if 'getLinks(Catalog' in open(ph, 'rb').read(): + poppler_cflags.append('-DPOPPLER_PRE_20') magick_error = None if not magick_inc_dirs or not os.path.exists(os.path.join(magick_inc_dirs[0], diff --git a/src/calibre/ebooks/pdf/reflow.cpp b/src/calibre/ebooks/pdf/reflow.cpp index 552e13efcb..c01f357d3c 100644 --- a/src/calibre/ebooks/pdf/reflow.cpp +++ b/src/calibre/ebooks/pdf/reflow.cpp @@ -647,7 +647,12 @@ void XMLOutputDev::process_link(AnnotLink* link){ void XMLOutputDev::endPage() { +#ifdef POPPLER_PRE_20 Links *slinks = catalog->getPage(current_page->number())->getLinks(catalog); +#else + Links *slinks = catalog->getPage(current_page->number())->getLinks(); +#endif + for (int i = 0; i < slinks->getNumLinks(); i++) { this->process_link(slinks->getLink(i)); @@ -878,7 +883,11 @@ vector* Reflow::render_first_page(bool use_crop_box, double x_res, throw ReflowException("Failed to allocate SplashOutputDev"); } try { +#ifdef POPPLER_PRE_20 out->startDoc(doc->getXRef()); +#else + out->startDoc(doc); +#endif out->startPage(1, NULL); double pg_w, pg_h;