Bug 104718

Summary: Cannot obtain linkmapping information in python/gjs
Product: poppler Reporter: max <m.duell>
Component: glib frontendAssignee: poppler-bugs <poppler-bugs>
Status: RESOLVED MOVED QA Contact:
Severity: normal    
Priority: medium CC: m.duell
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Python Code
Test pdf file
Vala code
Test pdf latex source

Description max 2018-01-21 20:00:22 UTC
Created attachment 136883 [details]
Python Code

Cannot obtain information about hyperlinks on the current page using python. 

This might also be a problem with the GLib bindings. The problem appears also using gjs bindings (will not post here unless specifically required), but with C and vala it appears to work correctly.

I attach a test pdf, generated using latex with a few hyperlinks and inner-document links.

With the attached vala code, I get the following output.


$ ./mini_linkmap
gotodest: 5
link: area: 158.232000 321.926000 290.983000 333.051000
link: 5 t: (null) u: https://gitlab.gnome.org/GNOME/pygobject
link: area: 398.028000 333.605000 478.476000 345.560000
link: 5 t: (null) u: https://gitlab.gnome.org/GNOME/pygobject
link: area: 258.578000 353.530000 427.942000 365.485000
link: 5 t: (null) u: https://poppler.freedesktop.org/
link: area: 132.772000 408.573000 218.450000 419.698000
link: 5 t: (null) u: https://poppler.freedesktop.org/
link: area: 392.798000 420.529000 478.476000 431.653000
link: 5 t: (null) u: https://poppler.freedesktop.org/
link: area: 435.948000 446.653000 442.922000 455.066000
   dest type 2 page 0 a: 0.000000 0.000000 0.000000 0.000000 z: 0.000000 n: cite.Random 
link: area: 383.416000 511.438000 390.390000 522.286000
   dest type 2 page 0 a: 0.000000 0.000000 0.000000 0.000000 z: 0.000000 n: section.1 


The python code should give a similar output. However, The URI strings are returned empty.

$ ./mini_linkmap.py crash2
link: area: 158.232000 321.926000 158.232000 333.051000
action type: uri
title: None
uri: ''
link: area: 398.028000 333.605000 398.028000 345.560000
action type: uri
title: None
uri: ''
link: area: 258.578000 353.530000 258.578000 365.485000
action type: uri
title: None
uri: ''
link: area: 132.772000 408.573000 132.772000 419.698000
action type: uri
title: None
uri: ''
link: area: 392.798000 420.529000 392.798000 431.653000
action type: uri
title: None
uri: ''
link: area: 435.948000 446.653000 435.948000 455.066000
action type: 2 goto_dest page 0 a: (0.0, 0.0, 0.0, 0.0) z: 0.0 dest type: <enum 31335872 of type Poppler.DestType>
link: area: 383.416000 511.438000 383.416000 522.286000
action type: 2 goto_dest page 0 a: (0.0, 0.0, 0.0, 0.0) z: 0.0 dest type: <enum 31337472 of type Poppler.DestType>




If the goto_dest named_dest string is queried, even the python interpreter crashes most times and sometimes yields garbage.

$ ./mini_linkmap.py crash
link: area: 158.232000 321.926000 158.232000 333.051000
action type: uri
link: area: 398.028000 333.605000 398.028000 345.560000
action type: uri
link: area: 258.578000 353.530000 258.578000 365.485000
action type: uri
link: area: 132.772000 408.573000 132.772000 419.698000
action type: uri
link: area: 392.798000 420.529000 392.798000 431.653000
action type: uri
link: area: 435.948000 446.653000 435.948000 455.066000
action type: 2 goto_dest page 0 a: (0.0, 0.0, 0.0, 0.0) z: 0.0 dest type: <enum 28583360 of type Poppler.DestType>
**
ERROR:../../gi/pygi-argument.c:1004:_pygi_argument_to_object: code should not be reached
Aborted

Example of random garbage:

$ ./mini_linkmap.py crash
link: area: 158.232000 321.926000 158.232000 333.051000
action type: uri
link: area: 398.028000 333.605000 398.028000 345.560000
action type: uri
link: area: 258.578000 353.530000 258.578000 365.485000
action type: uri
link: area: 132.772000 408.573000 132.772000 419.698000
action type: uri
link: area: 392.798000 420.529000 392.798000 431.653000
action type: uri
link: area: 435.948000 446.653000 435.948000 455.066000
action type: 2 goto_dest page 0 a: (0.0, 0.0, 0.0, 0.0) z: 0.0 dest type: <enum 24778176 of type Poppler.DestType>
title: None n: 0ƈ
link: area: 383.416000 511.438000 383.416000 522.286000
action type: 2 goto_dest page 0 a: (0.0, 0.0, 0.0, 0.0) z: 0.0 dest type: <enum 24779840 of type Poppler.DestType>
title: None n: 0ƈ
Comment 1 max 2018-01-21 20:01:23 UTC
Created attachment 136884 [details]
Test pdf file
Comment 2 max 2018-01-21 20:02:00 UTC
Created attachment 136885 [details]
Vala code

Vala code compiled using

valac --pkg poppler-glib --pkg gtk+-3.0 -o mini_linkmap mini_linkmap.vala
Comment 3 max 2018-01-21 20:02:31 UTC
Created attachment 136886 [details]
Test pdf latex source

Compile using `pdflatex hyperlinks.tex`
Comment 4 max 2018-01-21 20:05:31 UTC
Note also the garbage returned for the desttype enum.
Comment 5 Daniel Stone 2018-08-21 12:09:22 UTC
Sorry, but for some reason Bugzilla failed to generate valid XML to export this bug when migrating to GitLab. As a result we've been unable to duplicate it there. Please file a new issue on https://gitlab.freedesktop.org/poppler/poppler/issues/new/ referencing this one. Thanks, and sorry again for the inconvenience.

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.