From 56a9bab76d340530048bf0dea1e858701299fa29 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 26 Dec 2020 17:54:07 -0800 Subject: [PATCH] cairo: Label pages in PDFs with page numbers. These normally wouldn't do much, but PSPP does support an "initial page number" setting, and if that is set to anything but 1 then it will make a difference. --- src/output/cairo-pager.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/output/cairo-pager.c b/src/output/cairo-pager.c index 6249a3ab8e..1ab481f0c3 100644 --- a/src/output/cairo-pager.c +++ b/src/output/cairo-pager.c @@ -322,6 +322,14 @@ xr_pager_add_page (struct xr_pager *p, cairo_t *cr) fs->size[H], fs->size[V] + ps->object_spacing, fs->font_resolution); + cairo_surface_t *surface = cairo_get_target (cr); + if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_PDF) + { + char *page_label = xasprintf ("%d", page_number); + cairo_pdf_surface_set_page_label (surface, page_label); + free (page_label); + } + xr_pager_run (p); } -- 2.30.2