07-06-2010, 03:57 PM | #1 |
frumious Bandersnatch
Posts: 7,541
Karma: 19001081
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
epub2pdf script, now with GUI!
So... someone told me that I should create a GUI version of my epub2pdf.sh script, and after some time I bit the bullet and had a quick learning of python and Qt. This is a first working version of the thing. It not only generates PDF files from ePUB (if you have prince installed), but also creates thumbnails for use in the Cybooks (if you have convert installed). I think the interface is quite self-explanatory, at least for someone who knows more or less what the program is meant to do.
I'm sure there are many things that can be improved or added, and I'm open to suggestions. Something I'd like to do but I don't know how is having the output from prince redirected to some pop-up window (currently, the whole GUI just freezes while it runs), I'd appreciate any help with this. Umm... as I said, it's a python script with PyQt4, so I guess both of them are needed. I have them in my linux box, and it works here, but I know nothing about MacOS or Windows. Command line version Calibre plugin version EDIT (v 1.1): Fixed detection of Book CSS Included default CSS Added tab to view CSS files in the ePUB The generated PDF now includes correct title and author (or so I hope) EDIT (v 1.2): Fixed some issues in Windows Fixed PDF metadata Show only image files for possible covers Show also HTML files in CSS viewer EDIT (v 1.3): Decode percent-encoded filenames Fixed file path computation for non-UNIX filesystems (again) Fixed metadata setting (truncate modified file on writing) Fixed treatment of empty creators EDIT (v 1.4): There's apparently a bug in Prince that means links with directory separator do not work correctly in Windows, unless the command line is passed with unix/http-style paths. I hope it works fine with this version. Last edited by Jellby; 12-26-2013 at 08:50 AM. |
07-06-2010, 05:08 PM | #2 |
Addict
Posts: 281
Karma: 52007
Join Date: Jun 2010
Device: nook
|
Yes, you will have to install PyQt as well as Python. It is available here:
http://www.riverbankcomputing.com/so.../pyqt/download There is an automated installer for Windows, I fear that Mac OS users will have to read the install instructions. |
Advert | |
|
07-06-2010, 07:54 PM | #3 |
zeldinha zippy zeldissima
Posts: 27,827
Karma: 921169
Join Date: Dec 2007
Location: Paris, France
Device: eb1150 & is that a nook in her pocket, or she just happy to see you?
|
wow. impressive and brilliant. thank you jellby.
|
07-09-2010, 01:24 AM | #4 |
Wizard
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
|
Thanks for the new GUI version. Works for me.
I have one quick suggestion. The old version of the script came packaged with a default extra CSS you could use and modify to your preferences. I think it would be nice if there were something similar here. Perhaps if you clicked the CSS tab, you'd have something filled in for you by default, which you could modify if you wished: or perhaps, if that's too hands-on, something like that where it is all commented out but you could uncomment suggested options as you wished. I don't think you can expect to provide a full GUI for people who know no CSS whatever to just choose all the CSS options there are. But especially when it comes to Prince-specific CSS like setting the page sizes and hyphenation options, etc., it would be nice to see a sample. Defaulting to letter-sized paper with very little margins isn't likely to help anyone. Further along the same lines, you might even show the user the CSS files already contained in the ePub and let them modify them too directly, though I can imagine that would be difficult to implement. Still, it's a great script as is. Thanks again! |
07-09-2010, 12:52 PM | #5 | ||
frumious Bandersnatch
Posts: 7,541
Karma: 19001081
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
Quote:
|
||
Advert | |
|
07-12-2010, 02:10 PM | #6 |
frumious Bandersnatch
Posts: 7,541
Karma: 19001081
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
I've updated the script with some improvements:
|
07-17-2010, 11:01 AM | #7 |
Junior Member
Posts: 3
Karma: 10
Join Date: Nov 2009
Device: Hanvon N516
|
I keep getting "NameError: global name 'meta' is not defined" on line 205 as an error. Anybody else?
My guess: change line 205 from Code:
if meta.getAttribute("name") == "author": Code:
if child.getAttribute("name") == "author": Thanks a ton for epub2pdf.sh and the new GUI! |
07-17-2010, 12:27 PM | #8 |
frumious Bandersnatch
Posts: 7,541
Karma: 19001081
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Good guess! It was one of the many bugs in the script That's only a problem if the first XHTML file has an author in the head, which is not always the case.
|
07-25-2010, 07:23 AM | #9 |
Created Sigil, FlightCrew
Posts: 1,982
Karma: 350515
Join Date: Feb 2008
Device: Kobo Clara HD
|
Great work Jellby! Very nice indeed.
But you won't get many Windows users without an installer. For Windows, you should freeze the python script into an exe and bundle the dependencies into the installer. Hey I'm perfectly satisfied with the bash script which I use on my Ubuntu box, I'm just saying the average Windows user needs a bit more hand-holding. |
07-25-2010, 07:31 AM | #10 |
frumious Bandersnatch
Posts: 7,541
Karma: 19001081
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
And I don't say you are not right. But I don't even have a Windows computer to test it, so that's something I can't do at the moment
|
07-26-2010, 03:32 PM | #11 |
Addict
Posts: 281
Karma: 52007
Join Date: Jun 2010
Device: nook
|
Yes, one can freeze the python script into a Windows exe by using a program called Py2Exe, but this is a complicated process not for the faint of heart. (the corresponding program for a Macintosh is Py2App)
|
07-26-2010, 03:42 PM | #12 |
creator of calibre
Posts: 44,769
Karma: 24967300
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Yeah, one of the biggest annoyances (from the perspective of a linux developer) is how painful it is to make "installers" for other platforms. I remember I started out with py2exe/py2app for calibre. But they proved insufficient as calibre grew and I ended up writing my own replacements for them.
|
09-08-2010, 04:16 PM | #13 |
Junior Member
Posts: 7
Karma: 10
Join Date: Sep 2010
Location: California
Device: PRS-505
|
Hello, and thanks for a script.
I have succesfully ran it under Windows 7, although got to change couple lines to fix some windows-specific issues (like back-slash paths and file permissions). But I have a problem with links (like endnotes). Looks like Prince resolved relative urls in the source like "notes.html#note_1" to a absolute paths of temporary files like "c:\users\blabla\temp\blabla\notes.html#note_1 " which obviously doesn't work in the resulting pdf. Is it a common problem? Or is it just me? Or my particular book? Or my Windows 7? Can we somehow tell Prince to make all links internal? Last edited by viktorz; 09-08-2010 at 04:23 PM. |
09-09-2010, 11:41 AM | #14 | ||
frumious Bandersnatch
Posts: 7,541
Karma: 19001081
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
"Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later)." I think I've fixed it now, could you try the new 1.2 version? You may have to modify the "prince" filename again, or include in your system's path. Quote:
|
||
09-09-2010, 04:11 PM | #15 |
Junior Member
Posts: 7
Karma: 10
Join Date: Sep 2010
Location: California
Device: PRS-505
|
No, it is not quite right yet. Please see file attached, specifically the method "file" that I have changed. See, I just replaced the slash? That makes it work, otherwise reading from zip fails because of the wrong slash:
Code:
Traceback (most recent call last): File "C:\Utils\epub2pdf\epubutils_2.py", line 493, in loadFile self.fileLoaded(unicode(filename)) File "C:\Utils\epub2pdf\epubutils_2.py", line 497, in fileLoaded self.epub = ePUB(filename) File "C:\Utils\epub2pdf\epubutils_2.py", line 66, in __init__ self.readMetadata() File "C:\Utils\epub2pdf\epubutils_2.py", line 110, in readMetadata pages = int(math.ceil(zfile.getinfo(file).compress_size/1024.0)) File "C:\Python27\lib\zipfile.py", line 818, in getinfo 'There is no item named %r in the archive' % name) KeyError: "There is no item named u'OPS\\\\cover.xhtml' in the archive" Last edited by viktorz; 09-09-2010 at 04:18 PM. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
GUI bug? | edbro | Calibre | 2 | 06-19-2010 10:55 AM |
has anyone tried epub2pdf ? | frabjous | Workshop | 2 | 01-04-2010 03:01 PM |
Gui confusements. | brewt | Calibre | 8 | 12-30-2008 01:16 PM |
epub2pdf | touch_elango | Introduce Yourself | 2 | 10-25-2008 11:36 AM |
Mobi2Mobi GUI Batch | Jad | Kindle Formats | 8 | 10-22-2008 08:22 AM |