def walk_pages (page)
if page[:Type] == :Pages
callback(:begin_page_container, [page])
res = @xref.object(page[:Resources])
resources.push res if res
@xref.object(page[:Kids]).each {|child| walk_pages(@xref.object(child))}
resources.pop if res
callback(:end_page_container)
elsif page[:Type] == :Page
callback(:begin_page, [page])
res = @xref.object(page[:Resources])
resources.push res if res
walk_resources(current_resources)
if @xref.object(page[:Contents]).kind_of?(Array)
contents = @xref.object(page[:Contents])
else
contents = [page[:Contents]]
end
contents.each do |content|
obj = @xref.object(content)
content_stream(obj)
end if page.has_key?(:Contents) and page[:Contents]
resources.pop if res
callback(:end_page)
end
end