Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 04-07-2010, 05:22 AM   #1
grimborg
Enthusiast
grimborg shares his or her toysgrimborg shares his or her toysgrimborg shares his or her toysgrimborg shares his or her toysgrimborg shares his or her toysgrimborg shares his or her toysgrimborg shares his or her toysgrimborg shares his or her toysgrimborg shares his or her toysgrimborg shares his or her toysgrimborg shares his or her toys
 
Posts: 41
Karma: 5514
Join Date: Oct 2009
Location: Groningen, Netherlands
Device: PRS-T1
Thumbs up patch: LrfError: page id invalid in toc

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
grimborg is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PRS-505 Invalid Page PieOPah Sony Reader 7 12-30-2011 11:48 AM
Redundant/Invalid TOC entries Stinger Kobo Reader 4 06-26-2010 09:02 PM
PRS-900 Help! Invalid Page Error cbnash Sony Reader 5 01-26-2010 09:50 AM
Single page "Invalid Page!" error Sony-505 2percentright Calibre 5 07-29-2009 11:22 AM
Problem with big PDF's on my SD card. invalid page. please help master4g Sony Reader 2 12-08-2007 02:57 PM


All times are GMT -4. The time now is 07:45 PM.


MobileRead.com is a privately owned, operated and funded community.