Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 01-11-2020, 04:18 PM   #1
rjnagle
Zealot
rjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it is
 
Posts: 116
Karma: 2167
Join Date: Oct 2005
Location: Houston, Texas
Device: ipad 1, Nook Simple Touch, Kindle 3, ebookwise 1150
EPUB --> PDF: problems adding custom headers

I had a problem adding a header when converting from EPUB to PDF. I'm on Windows 10 version 4.8

I create my valid epubs via docbook/html, but I use Calibre (instead of Docbook) to create on the fly PDFs for Advance Reading Copies from my epubs. When doing the conversion, I have used Calibre to add a header that says "Pre-release Version" or "Advance Reading Copy".

In previous versions I just added text to the Headers field in the PDF Output configuration options. But apparently when I do so, it gives an error message (See below).

Looking at the manual for the headers/footers, I see that you need to include some HTML and variables such as _TITLE_ and _AUTHOR_

When I tried using the sample code on the calibre docs, everything converted cleanly. But if I substituted my personalized text it produces an error.

Code:
HEADER style
   DIV class=even
   MY TEXT 
   DIV class = odd
/HEADER
or

Code:
HEADER style
   DIV class=even
     P
        MY TEXT
     p 
   DIV class = odd
/HEADER
Is there documentation about how to edit code for headers/footers for PDF output in Calibre to include custom text?

PS, I never realized that this tool has an editor. I plan to try it!


*************************************

calibre 4.8 embedded-python: True is64bit: False
Windows-10-10.0.18362-SP0 Windows ('32bit', 'WindowsPE')
....
Trimming u'OEBPS/cover.xhtml' from manifest
Trimming u'OEBPS/toc.ncx' from manifest
Creating PDF Output...
Converting input as a text based book...
The cover image has an id != "cover". Renaming to work around bug in Nook Color
Python function terminated unexpectedly
list index out of range (Error Code: 1)
Traceback (most recent call last):
File "site.py", line 114, in main
File "site.py", line 88, in run_entry_point
File "site-packages\calibre\utils\ipc\worker.py", line 209, in main
File "site-packages\calibre\gui2\convert\gui_conversion.py", line 43, in gui_convert_override
File "site-packages\calibre\gui2\convert\gui_conversion.py", line 28, in gui_convert
File "site-packages\calibre\ebooks\conversion\plumber.py", line 1275, in run
File "site-packages\calibre\ebooks\conversion\plugins\pdf_out put.py", line 188, in convert
File "site-packages\calibre\ebooks\conversion\plugins\pdf_out put.py", line 255, in convert_text
File "site-packages\calibre\ebooks\pdf\html_writer.py", line 1211, in convert
File "site-packages\calibre\ebooks\pdf\html_writer.py", line 1093, in add_header_footer
File "site-packages\calibre\ebooks\pdf\html_writer.py", line 1074, in format_template
File "src/lxml/etree.pyx", line 1165, in lxml.etree._Element.__getitem__
IndexError: list index out of range
rjnagle is offline   Reply With Quote
Old 01-11-2020, 10:37 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 36,072
Karma: 15014853
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You need < and > in your templates like this <header><div>my text</div></header>
kovidgoyal is offline   Reply With Quote
Advert
Old 01-12-2020, 12:59 AM   #3
rjnagle
Zealot
rjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it isrjnagle knows what time it is
 
Posts: 116
Karma: 2167
Join Date: Oct 2005
Location: Houston, Texas
Device: ipad 1, Nook Simple Touch, Kindle 3, ebookwise 1150
UPDATE: Yes, I removed the < and > from the forum comment -- I omitted it from the first post because I knew it gets mangled in forum posts.

With 3 different valid epubs, your simpler header code worked in the conversion.

That tells me that the problem is not with calibre or the environment but with the specific file.

After testing some more and adding the same file to calibre more than once, I see that a conversion failure will continue with the same file even if you correct or simplify the header code.. I.E., if I try a second time to convert after a failed conversion, it reliably continues to show errors (even if you correct the code snippet or leave it blank).

The workaround is to add the epub again to calibre, and add correct header code again in the PDF OUTPUT. A fresh conversion always works.
rjnagle is offline   Reply With Quote
Old 01-12-2020, 12:10 PM   #4
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 24,577
Karma: 34133293
Join Date: Aug 2009
Location: The Central Coast of California
Device: K4NT(RIP), Galaxy Tab A, Kobo Aura2
The forum will NOT mangle those if put into [code] tags (the # on the advanced screen. IMHO Calibre posters should hide the Quick reply and have the forums set to Advanced. It just offers MORE icons to use and still allows simple use elsewhen )
theducks is offline   Reply With Quote
Reply

Tags
calibre, conversion from .pdf

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help adding a custom news source (PDF) needed. inte Recipes 2 11-09-2017 05:22 AM
Epub to PDF can't remove page breaks between headers Vykan12 Calibre 11 07-25-2012 04:01 AM
problems adding cover to epub thaKing Calibre 5 07-06-2011 11:17 PM
PDF to ePub conversion issue - headers getting left in deadSkip Calibre 7 07-09-2010 03:07 AM
Evading headers in PDF->EPUB conversion davef Calibre 6 08-29-2009 04:26 PM


All times are GMT -4. The time now is 09:37 AM.


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