Closed C9t0 closed 9 years ago
Ohhh i have found it! It was a bug in my code based on a ambiguous part in the poppler lib.
My correctly working version looks like this:
def __readToC(doc, inChapter: Chapter, node):
n = node.firstChildElement()
while(not n.isNull()):
#build up this chapter
subChapter = Chapter()
subChapter.title = n.tagName()
linkPage = 0
dest = n.attribute("Destination")
destName = n.attribute("DestinationName")
if (dest):
linkPage = popplerqt4.Poppler.LinkDestination(dest).pageNumber()
elif (destName):
linkPage = doc.linkDestination(destName).pageNumber()
subChapter.startPage = linkPage - 1
Book.__readToC(doc, subChapter, n)
inChapter.chapters.append(subChapter)
n = n.nextSiblingElement()
Great!! But thanks for taking the effort to report what could have been a buglet. Note that in your code linkDest
could be 0
, if the if
and elif
both fail :-)
Thanks for you comment, it was a really quick fix example ;-) Now this is also fixed :-D
And sorry that I have create a issue for a fault in my code.
Hi there, i have write a little recursive function to reads in a table of content and i try to get the pageNumber for each chapter via the linkDestination function. But the link call will always return 0 and a error message: "failed to look up ..."
I use Ubuntu 14.04 with the latest python3 version (3.4.0) and with installed poppler and qt4 packages from the ubuntu repo and i have only install python-poppler-qt4 alternative via pip3
I have try this on some more eBooks with large ToC's and always i would get this messages!
The readToc funcktion looks like:
and a print of from the toc and the link error message looks like:
Thanks a lot!