I'm using pdf2svg from http://www.cityinthesky.co.uk/opensource/pdf2svg/ toconvert PDF pages to SVG images. The key steps are as follows: // Open the SVG file surface = cairo_svg_surface_create(svgFilename, width, height); drawcontext = cairo_create(surface); // Render the PDF file into the SVG file poppler_page_render(page, drawcontext); cairo_show_page(drawcontext); For my purposes, this works well, with one exception: clickable links in the PDF page are not converted into links in the SVG image. SVG supports simple xlinks and cairo has a function cairo_surface_set_mime_data with CAIRO_MIME_TYPE_URI as a supported mime type. I believe links on a PDF page are available using poppler_page_get_link_mapping. Seems like this would be a useful enhancement to poppler_page_render for an svg_surface.
It's easy enough to access the necessary information using poppler_page_get_link_mapping; but I don't see any way to add xlinks to the svg surface other than by adding them to the svg file: LinkMappings = poppler_page_get_link_mapping (page); for (l = LinkMappings; l != NULL; l = l->next) { PopplerLinkMapping *plm = l->data; PopplerRectangle rect = plm->area; PopplerAction *act = plm->action; if (act->type == POPPLER_ACTION_URI) { fprintf ( nsvg, "<a xlink:href=\"%s\" target=\"_blank\">\n", act->uri.uri); fprintf ( nsvg, "<rect fill-opacity=\"0.0\" "); fprintf ( nsvg, "x=\"%5.3f\" y=\"%5.3f\" ", rect.x1, height-rect.y2); fprintf ( nsvg, "width=\"%5.3f\" height=\"%5.3f\"/></a>\n", rect.x2-rect.x1, rect.y2-rect.y1); }
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/poppler/poppler/issues/497.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.