From 141870506d8809723e933963e9e001aca839cdfc Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 15 Nov 2016 14:13:47 +0100 Subject: pdf: Use '#page=N' for remote destination pages. As per Adobe's recommendation: https://helpx.adobe.com/acrobat/kb/link-html-pdf-page-acrobat.html --- source/pdf/pdf-annot.c | 2 +- source/pdf/pdf-page.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index b500d12f..2d6aab16 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -146,7 +146,7 @@ pdf_parse_file_spec(fz_context *ctx, pdf_document *doc, pdf_obj *file_spec, pdf_ #endif if (pdf_is_array(ctx, dest)) - fz_snprintf(buf, sizeof buf, "#%d", pdf_to_int(ctx, pdf_array_get(ctx, dest, 0)) + 1); + fz_snprintf(buf, sizeof buf, "#page=%d", pdf_to_int(ctx, pdf_array_get(ctx, dest, 0)) + 1); else if (pdf_is_name(ctx, dest)) fz_snprintf(buf, sizeof buf, "#%s", pdf_to_name(ctx, dest)); else if (pdf_is_stream(ctx, dest)) diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c index 2112040a..8335614a 100644 --- a/source/pdf/pdf-page.c +++ b/source/pdf/pdf-page.c @@ -214,8 +214,16 @@ pdf_lookup_anchor(fz_context *ctx, pdf_document *doc, const char *name) fz_catch(ctx) fz_rethrow(ctx); - uri = pdf_parse_link_dest(ctx, doc, dest); - return pdf_resolve_link(ctx, doc, uri, NULL, NULL); + if (dest) + { + uri = pdf_parse_link_dest(ctx, doc, dest); + return pdf_resolve_link(ctx, doc, uri, NULL, NULL); + } + + if (!strncmp(name, "page=", 5)) + return fz_atoi(name + 5) - 1; + + return fz_atoi(name) - 1; } static pdf_obj * -- cgit v1.2.3