Bug 809237 - failure to convert epub to pdf
Summary: failure to convert epub to pdf
Alias: None
Product: Fedora
Classification: Fedora
Component: calibre
Version: 16
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Kevin Fenzi
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2012-04-02 20:00 UTC by Gabriel Somlo
Modified: 2014-03-11 22:37 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2012-05-04 03:35:41 UTC
Type: ---

Attachments (Terms of Use)

Description Gabriel Somlo 2012-04-02 20:00:07 UTC
Description of problem:
calibre fails to convert an epub to pdf

Version-Release number of selected component (if applicable):

How reproducible:
load an epub book into calibre, then attempt to convert it to pdf

Steps to Reproduce:
1. load ebook (in .epub format) into calibre
2. click "convert books"
3. pick "pdf" as output
Actual results:
error message: "Exception: Empty output file, probably the conversion process crashed"

show details:

Traceback (most recent call last):
  File "/usr/lib64/calibre/calibre/gui2/__init__.py", line 340, in dispatch
    self.func(*args, **kwargs)
  File "/usr/lib64/calibre/calibre/gui2/actions/convert.py", line 176, in book_converted
    raise Exception(_('Empty output file, '
Exception: Empty output file, probably the conversion process crashed

Expected results:
a pdf file should be generated

Additional info:

Comment 1 Kevin Fenzi 2012-04-02 21:08:33 UTC
Can you run it from a terminal and see if there is any further output from the conversion?

Also, can you try the latest version from my side repo and see if the problem persists?

cd /etc/yum.repos.d/
wget http://repos.fedorapeople.org/repos/kevin/calibre/fedora-calibre.repo
yum clean all
yum update calibre

Comment 2 Gabriel Somlo 2012-04-02 21:27:56 UTC
It spits this to the xterm I launched it from:

Traceback (most recent call last):
  File "/usr/lib64/calibre/calibre/gui2/__init__.py", line 340, in dispatch
    self.func(*args, **kwargs)
  File "/usr/lib64/calibre/calibre/gui2/actions/convert.py", line 176, in book_converted
    raise Exception(_('Empty output file, '
Exception: Empty output file, probably the conversion process crashed

(mostly the same thing I got from the 'show details' GUI window...

Version 0.8.45 from your side repo crashes with an almost identical error (it's line 346 in __init.py__ instead of 340).

Comment 3 Kevin Fenzi 2012-04-03 18:43:18 UTC
Does this happen with any epub file? Or just a particular one?

If you use 'ebook-convert foo.epub foo.pdf' from the command line do you get any more output?

Comment 4 Gabriel Somlo 2012-04-04 13:06:39 UTC
I tried a second epub, and ran into the same problem. When I run ebook-convert, I get this:

$ ebook-convert example.epub example.epub example.pdf

1% Converting input to HTML...
InputFormatPlugin: EPUB Input running
on ./example.epub
Found HTML cover titlepage.xhtml
Parsing all content...
34% Running transforms on ebook...
Merging user specified metadata...
Detecting structure...
Flattening CSS and remapping font sizes...
Source base font size is 12.00000pt
Removing fake margins...
Cleaning up manifest...
Trimming unused files from manifest...
Creating PDF Output...
67% Creating PDF Output
The cover image has an id != "cover". Renaming to work around bug in Nook Color
loaded the Generic plugin 
Traceback (most recent call last):
  File "/usr/lib64/calibre/calibre/ebooks/pdf/writer.py", line 185, in _render_html
  File "/usr/lib64/calibre/calibre/ebooks/pdf/writer.py", line 151, in _render_book
  File "/usr/lib64/calibre/calibre/ebooks/pdf/writer.py", line 217, in _write
    outPDF = PdfFileWriter(title=self.metadata.title, author=self.metadata.author)
TypeError: __init__() got an unexpected keyword argument 'title'

Comment 5 Kevin Fenzi 2012-04-04 18:07:36 UTC
ok, this is due to calibre depending on it's own bundled pyPdf (which we don't bundle in Fedora). 

I will need to see if I can tweak it to work with the normal pyPdf, or get the changes in the Fedora pyPDF. ;(

Comment 6 Mihai Limbășan 2012-04-24 16:54:59 UTC
The main problem, as I see it, is that calibre's pyPdf version diverges considerably from upstream.

Patching it is not a matter of adjusting a few method signatures here and there - the diff from calibre's version (whichever that is, wasn't able to find out) to F16's pyPdf (1.13) runs to almost 18k. The entire pyPdf source tree, including README and setup.py and whatnot, is 84k.

I've beaten my head against this problem repeatedly for the past couple of years every time it reared its head (which was quite a few times), and unfortunately the only reasonable course of action I've found so far is to simply not drop the bundled pyPdf.

I know this suggestion runs contrary to Fedora's policy of unbundling libraries, but in this case I don't see any other reasonable choice, unless you want to fix the same class problem again and again and again every time the calibre source tree becomes incompatible with the current version of the pyPdf patch.

Should you try to do that - the necessary changes to the spec file are minimal:
  - remove the pyPdf dependency (Requires: pyPdf)
  - remove pyPdf from the list of subdirectories to be deleted from the build tree (this one's towards the end of %install, ~15 lines above %post; search for the comment "# these are provided as separate packages")

Comment 7 Mihai Limbășan 2012-04-24 16:57:53 UTC
Oh, forgot to add: Please don't get calibre's pyPdf changes into Fedora's pyPdf, the API is too different (e.g., the mail class constructor takes an additional required parameter, title) and you'll break and will have to patch every single package using pyPdf :(

Comment 8 Kevin Fenzi 2012-04-24 19:42:45 UTC
Yeah, sadly I'm all too aware of that. 

In order to bundle this, I need an exception from the fedora packaging commitee. 
I'll try and find time to request one and see what they say.

Comment 9 Mihai Limbășan 2012-05-01 14:21:44 UTC
Additional (somewhat unrelated) info:

Beginning with 0.8.49, calibre requires cssutil 0.9.9, which isn't included in Fedora 16 or 17 (and, as far as I can see, neither in rawhide.)

Patching calibre to work with the older version is, as usual, a very annoyuing chose. Should anyone want to get cssutils 0.9.9 included, you can start from this SRPM: http://rpms.limbasan.ro/fedora/16/SRPMS/python-cssutils-0.9.9-1.fc16.src.rpm

Comment 10 Kevin Fenzi 2012-05-04 03:35:41 UTC
Yeah, I filed bug 818799 to ask the maintainer to update... thanks for seeing that. 

The FPC did give me the exception to bundle pyPdf, so thats now fixed in rawhide, and will push out to other releases as they are updated. ;)

Comment 11 Mihai Limbășan 2012-05-04 04:57:29 UTC
Yay, that's very good news indeed, congratulations :)

Comment 12 tvizirov 2014-03-11 22:37:12 UTC
  Maybe a bit late, but just wanted to confirm that the current version:
calibre-1.27.0-x86_64.tar.bz2 have no problems converting files on Fedora 16. 

It can be downloaded from here: 

$  uname -r

Note You need to log in before you can comment on or make changes to this bug.