Bug 75953 - PDF links -> SVG
Summary: PDF links -> SVG
Status: RESOLVED MOVED
Alias: None
Product: poppler
Classification: Unclassified
Component: glib frontend (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-09 16:59 UTC by rdtennent
Modified: 2018-08-21 11:04 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description rdtennent 2014-03-09 16:59:29 UTC
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.
Comment 1 rdtennent 2014-04-05 16:40:19 UTC
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);   
           }
Comment 2 GitLab Migration User 2018-08-21 11:04:16 UTC
-- 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.