Menu

#170 Poppler::IndexIter#child doesn't seem to descend

open
nobody
None
5
2012-12-11
2011-07-03
unlimited
No

Hi. I'm rather confused. I looked at the code and what I'm reporting here makes absolutely no sense to me, but I'm doing it anyway, as I believe I have no other option.
So, it seems to be impossible to reach any node within the document outline, below the toplevel nodes. This is the code I'm using to test it:
<pre>
require 'rubygems'
require 'poppler'

doc = Poppler::Document.new("example.pdf")

def print_tree(iter)
puts iter.action.title
if child = iter.child
puts "desc"
print_tree(iter)
end
if iter.next
puts "next"
print_tree(iter)
end
end

print_tree(doc.index_iter)
</pre>

My test document (actually mirror.ctan.org/biblio/bibtex/utils/alphabib/example.pdf) has one toplevel node, with several children. The code above though, prints the toplevel node until SystemStackError occurs. The child nodes are never accessed.

To verify that my understanding of the Poppler API is correct, I tried the same in python:
<pre>
import poppler

doc = poppler.document_new_from_file("file:///home/nilclass/poppler-bug/example.pdf", "")

def print_tree(iter):
print iter.get_action().title
child = iter.get_child()
if(child):
print "desc"
print_tree(child)
if(iter.next()):
print "next"
print_tree(iter)

print_tree(poppler.IndexIter(doc))
</pre>

This works as expected, so I believe the error is somewhere within the ruby bindings.

Versions:
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
poppler 0.16.4 (ubuntu packages libpoppler13 and libpoppler-glib6)
poppler gem 0.90.9

Anyway, thank's a lot for all the rest of ruby-gnome that works wonderfully :)

Discussion

  • unlimited

    unlimited - 2011-07-03

    this is bullshit. I had an obvious error in my code, so here's the new version:

    require 'rubygems'
    require 'poppler'

    doc = Poppler::Document.new("example.pdf")

    def print_tree(iter)
    puts iter.action.title if iter.action
    if child = iter.child
    puts "desc"
    print_tree(child)
    end
    if iter.next
    puts "next"
    print_tree(iter)
    end
    end

    print_tree(doc.index_iter)

    The error described above was obviously an error in my code, but what I'm experiencing now is, that within all second-level nodes the "action" method returns nil (hence the added check). All nodes are visited ("desc"/"next" printed as expected), though the action is empty. Needless to say - I'm even more confused than before.

    Sorry for the mess.

     
  • Kouhei Sutou

    Kouhei Sutou - 2011-07-03

    Could you give us an example PDF?

     
  • Kouhei Sutou

    Kouhei Sutou - 2011-12-25

    It's not a confirmed bug yet. Could you also give us an example PDF?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.