Hi,
I was getting this error when converting an epub to lrf:
Code:
calibre.ebooks.lrf.pylrs.pylrf.LrfError: page id invalid in toc: Photo Credits
(see below for the complete trace)
I changed the code so that when it finds an invalid pageId/objId when generating the toc, it will just use the previous one instead. Granted, it's not very pretty but a book with a sightly inaccurate toc is better than no book

I tested it and my PRS-505 can paginate the resulting lrf with no problems.
Here's the diff and the full trace of the error. I'm running calibre on Ubuntu 9.10 (calibre version 0.6.13+dfsg-0ubuntu3.1)
Enjoy!
Diff:
Code:
*** /usr/lib/calibre/calibre/ebooks/lrf/pylrs/pylrf.py 2009-09-18 20:58:46.000000000 +0200
--- pylrf.py 2010-04-07 11:11:59.000000000 +0200
***************
*** 592,604 ****
lastOffset += entryLen
writeDWord(stream, lastOffset)
for entry in toc:
pageId, objId, label = entry
if pageId <= 0:
! raise LrfError, "page id invalid in toc: " + label
! if objId <= 0:
! raise LrfError, "textblock id invalid in toc: " + label
!
writeDWord(stream, pageId)
writeDWord(stream, objId)
writeUnicode(stream, label, se)
--- 592,607 ----
lastOffset += entryLen
writeDWord(stream, lastOffset)
+ lastEntry=None
for entry in toc:
pageId, objId, label = entry
if pageId <= 0:
! print "page id invalid in toc: " + label
! pageId=lastEntry[0] if lastEntry else 1
! elif objId <= 0:
! print "textblock id invalid in toc: " + label
! objId=lastEntry[1] if lastEntry else 1
! lastEntry=entry
writeDWord(stream, pageId)
writeDWord(stream, objId)
writeUnicode(stream, label, se)
Trace of the error this solves:
Code:
Traceback (most recent call last):
File "/tmp/init.py", line 48, in <module>
File "/home/kovid/build/calibre/src/calibre/ebooks/conversion/cli.py", line 254, in main
File "/home/kovid/build/calibre/src/calibre/ebooks/conversion/plumber.py", line 898, in run
File "/home/kovid/build/calibre/src/calibre/ebooks/lrf/output.py", line 191, in convert
File "/home/kovid/build/calibre/src/calibre/ebooks/lrf/html/convert_from.py", line 1939, in process_file
File "/home/kovid/build/calibre/src/calibre/ebooks/lrf/html/convert_from.py", line 1818, in writeto
File "/home/kovid/build/calibre/src/calibre/ebooks/lrf/pylrs/pylrs.py", line 623, in renderLrf
File "/home/kovid/build/calibre/src/calibre/ebooks/lrf/pylrs/pylrs.py", line 229, in toLrf
File "/home/kovid/build/calibre/src/calibre/ebooks/lrf/pylrs/pylrs.py", line 225, in toLrfDelegates
File "/home/kovid/build/calibre/src/calibre/ebooks/lrf/pylrs/pylrs.py", line 229, in toLrf
File "/home/kovid/build/calibre/src/calibre/ebooks/lrf/pylrs/pylrs.py", line 225, in toLrfDelegates
File "/home/kovid/build/calibre/src/calibre/ebooks/lrf/pylrs/pylrs.py", line 776, in toLrf
File "/home/kovid/build/calibre/src/calibre/ebooks/lrf/pylrs/pylrf.py", line 572, in __init__
File "/home/kovid/build/calibre/src/calibre/ebooks/lrf/pylrs/pylrf.py", line 598, in _makeTocStream
calibre.ebooks.lrf.pylrs.pylrf.LrfError: page id invalid in toc: Photo Credits