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

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 09-09-2010, 04:17 PM   #16
viktorz
Junior Member
viktorz began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Sep 2010
Location: California
Device: PRS-505
Quote:
Originally Posted by Jellby View Post
It doesn't happen to me, intra-ePUB links are transformed into intra-PDF links.
I think I have figured it out. The problem was two-fold

First, apparently there is a problem when prince gets absolute paths to the files in command-line. So I have modified script to pass file names only, and changed workdir for the prince in the Popen call. Again, see attached in the previous post. That produces working links - sometimes.

Now there is another problem, when the link happens to refer to an empty span. It depends on a book, obviously. I think it's a known bug in the prince.

Last edited by viktorz; 09-15-2010 at 05:39 AM.
viktorz is offline   Reply With Quote
Old 09-10-2010, 09:55 AM   #17
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,316
Karma: 4963983
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by viktorz View Post
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:
Hmm... I guess I had read it backwards. If I now understand it correctly, the problem is I was generating the pathnames with the OS-specific separator ("\" for windows), but zipfile's getinfo() wants them with "/" always? What I don't quite understand then is why prince works when you feed it the filenames with "/".

Could you run the attached file (load an ePUB and convert it to PDF) and copy whatever it outputs to the terminal? I'd like to see what's happening exactly to the file paths, or maybe you can explain it

Regarding you other changes, I've incorporated them, but haven't uploaded it yet.
Attached Files
File Type: zip epubutils_win.zip (7.2 KB, 207 views)
Jellby is offline   Reply With Quote
Old 09-11-2010, 01:52 AM   #18
viktorz
Junior Member
viktorz began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Sep 2010
Location: California
Device: PRS-505
Quote:
Originally Posted by Jellby View Post
Hmm... I guess I had read it backwards. If I now understand it correctly, the problem is I was generating the pathnames with the OS-specific separator ("\" for windows), but zipfile's getinfo() wants them with "/" always? What I don't quite understand then is why prince works when you feed it the filenames with "/".
I guess Prince is smart enough to take care of slashes. As a command-line parameters, those file paths are coming into the Prince as strings, right? And Prince is free to do with those strings whatever it wants. And if Prince is, like, "hey, those strings supposed to be file paths, but I am under Windows now, so I'd better make sure all slashes are right ones... I mean wrong ones..." - that would explain it, right?

Quote:
Originally Posted by Jellby View Post
Could you run the attached file (load an ePUB and convert it to PDF) and copy whatever it outputs to the terminal? I'd like to see what's happening exactly to the file paths, or maybe you can explain it
Here you are:
Code:
OPS\cover.xhtml
OPS\ch1.xhtml
OPS\ch2.xhtml
OPS\ch3.xhtml
OPS\ch4.xhtml
OPS\ch5.xhtml
OPS\ch6.xhtml
OPS\ch7.xhtml
OPS\ch8.xhtml
OPS\ch9.xhtml
OPS\ch10.xhtml
OPS\ch11.xhtml
OPS\ch12.xhtml
OPS\ch13.xhtml
OPS\ch14.xhtml
OPS\ch15.xhtml
OPS\ch16.xhtml
OPS\ch17.xhtml
OPS\ch18.xhtml
OPS\ch19.xhtml
OPS\ch20.xhtml
OPS\ch21.xhtml
OPS\ch22.xhtml
OPS\ch23.xhtml
OPS\ch24.xhtml
OPS\ch25.xhtml
OPS\ch26.xhtml
OPS\ch27.xhtml
OPS\ch28.xhtml
OPS\ch29.xhtml
OPS\ch30.xhtml
OPS\ch31.xhtml
OPS\ch32.xhtml
OPS\ch33.xhtml
['C:\\Program Files\\Prince\\Engine\\bin\\prince.exe', '-v', '-s', 'c:\\users\\myname\\appdata\\local\\temp\\tmpxt9o1b\\tmp6gghkl', '-o', 'C:\\Utils\\epub2pdf
\\epub2pdf.pdf', u'OPS/cover.xhtml', u'OPS/ch1.xhtml', u'OPS/ch2.xhtml', u'OPS/c
h3.xhtml', u'OPS/ch4.xhtml', u'OPS/ch5.xhtml', u'OPS/ch6.xhtml', u'OPS/ch7.xhtml
', u'OPS/ch8.xhtml', u'OPS/ch9.xhtml', u'OPS/ch10.xhtml', u'OPS/ch11.xhtml', u'O
PS/ch12.xhtml', u'OPS/ch13.xhtml', u'OPS/ch14.xhtml', u'OPS/ch15.xhtml', u'OPS/c
h16.xhtml', u'OPS/ch17.xhtml', u'OPS/ch18.xhtml', u'OPS/ch19.xhtml', u'OPS/ch20.
xhtml', u'OPS/ch21.xhtml', u'OPS/ch22.xhtml', u'OPS/ch23.xhtml', u'OPS/ch24.xhtm
l', u'OPS/ch25.xhtml', u'OPS/ch26.xhtml', u'OPS/ch27.xhtml', u'OPS/ch28.xhtml',
u'OPS/ch29.xhtml', u'OPS/ch30.xhtml', u'OPS/ch31.xhtml', u'OPS/ch32.xhtml', u'OP
S/ch33.xhtml']
viktorz is offline   Reply With Quote
Old 09-11-2010, 05:13 AM   #19
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,316
Karma: 4963983
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
OK, so apparently the only source of pernicious "\" is the os.path.join, when used to read files from the ZIP. Then the best solution is probably not using os.path.join, but simply adding a hard-coded "/" when needed. I've done this in a few places. For the actual prince run, even though it seems it's not needed, I've replaced "/" with the OS-specific path separator, just to be "cleaner".

Please try this and tell me how it works.
Attached Files
File Type: zip epubutils.zip (7.1 KB, 332 views)
Jellby is offline   Reply With Quote
Old 09-11-2010, 05:53 AM   #20
viktorz
Junior Member
viktorz began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Sep 2010
Location: California
Device: PRS-505
Works OK
viktorz is offline   Reply With Quote
Old 10-20-2010, 08:58 PM   #21
tonhou
Member
tonhou began at the beginning.
 
Posts: 14
Karma: 10
Join Date: Feb 2010
Device: Jetbook
I have a question concerning the table of content generated.
At present my reader (Jetbook) can only read one level of TOC (no sub-levels), other wise it crashes the reader. The epub2pdf generator does a superb job of creating a TOC, but I would like to limit it to the top level.
Is this possible? What do I need to do?

Thanks.
--Tony
tonhou is offline   Reply With Quote
Old 10-21-2010, 08:01 AM   #22
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,316
Karma: 4963983
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by tonhou View Post
The epub2pdf generator does a superb job of creating a TOC, but I would like to limit it to the top level.
Is this possible? What do I need to do?
Do you mean the "bookmarks" that are created for the PDF, and which you can display or hide in Acrobat for instance? Those are created by Prince, have a look here. You could add "h3 { prince-bookmark-level: none; }" or similar to the additional CSS, it depends on how the specific ePUB is coded.

If you mean an inline TOC, which appears just as a normal page (or many pages) in the PDF, then that's hard-coded in the ePUB, and you'd have to edit it.
Jellby is offline   Reply With Quote
Old 10-23-2010, 01:35 AM   #23
tonhou
Member
tonhou began at the beginning.
 
Posts: 14
Karma: 10
Join Date: Feb 2010
Device: Jetbook
Thank you for the reply.
Yes I believe I meant the bookmarks that are created as a popup TOC in my reader (and as a side bar in Linux pdf readers).
I have tried your suggestion and it did bring some changes, though I am still a bit bewildered as to how to get just the top level eg:
Chapter 1 -->Headings -->Sub-headings
Chapter 2 -->Headings --> Sub-headings
Chapter 3 --> Headings --> Sub-headings
etc

I only want Chapter 1, Chapter 2, Chapter 3 and none of the other nested headings.
I shall keep experimenting and see if I can happen on to it.

Thanks again.
--Tony
tonhou is offline   Reply With Quote
Old 10-23-2010, 05:22 AM   #24
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,316
Karma: 4963983
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
You'd have to take a look at the code (which you can do selecting the html files in the drop-down list next to "CSS files" in epubutils.py) and see what is used for Chapter 1 (maybe <h1>Chapter 1</h1>), what for Headings (maybe <h2>Headings</h2>) and what for Sub-heading (maybe <h3>Sub-heading</h3>). Then you should modify the CSS rules passed to prince accordingly, by adding "prince-bookmark-level: none;" to the elements you don't want in the TOC.
Jellby is offline   Reply With Quote
Old 03-20-2011, 03:53 PM   #25
insomniac-
Junior Member
insomniac- began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Mar 2011
Device: iLiad 2
epubutils with slight modifications

Hi people,
maybe it's a too old thread, but here it is. I needed to convert from ePUB to PDF in a decent quality, and I landed onto this forum. The tool written by Jellby works fine and has a nice GUI, but I had troubles converting a number of ePUB files. So I modified the code (it required the Author field to be non-empty), and also added some code to remove the annoying PrinceXML annotation on the first page of the PDF. I also created a python package (by adding a setup.py script and splitting the code into library and start script). If Jellby or anyone is interested, let me know and I'll publish the code.

Bye
insomniac
insomniac- is offline   Reply With Quote
Old 03-20-2011, 03:57 PM   #26
insomniac-
Junior Member
insomniac- began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Mar 2011
Device: iLiad 2
Quote:
Originally Posted by insomniac- View Post
So I modified the code (it required the Author field to be non-empty), and also added some code to remove the annoying PrinceXML annotation on the first page of the PDF.
Forgot to mention, for the annotation stripping it requires the pyPDF package. If it's not available on the system, it will silently skip this operation.

insomniac
insomniac- is offline   Reply With Quote
Old 03-21-2011, 03:40 PM   #27
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,316
Karma: 4963983
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
I would like to see the modifications at least, and incorporate them in my version if you don't mind

Except for removing the Prince logo. It's good if you can do it yourself (and I have something similar too), but since the Prince people offer a free version and expect those wanting the "full" version (without the logo) to pay, I think it's rather unfair to them to offer such a tool pre-packaged.
Jellby is offline   Reply With Quote
Old 03-22-2011, 08:16 AM   #28
insomniac-
Junior Member
insomniac- began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Mar 2011
Device: iLiad 2
Excluding the logo removal, the project didn't change much, except for a re-packaging and a try..except on the author name. I'm sending you a PM with the link to the sources, feel free to take only what you need and include in your project :-)

Cheers,
insomniac
insomniac- is offline   Reply With Quote
Old 12-20-2011, 07:54 AM   #29
Jon Hurst
Junior Member
Jon Hurst began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Dec 2011
Device: prs-350
Thankyou!

Jellby - I've been looking for this for ages. Works great! I was just about to start down a route of XSLT and FO - you've probably saved me about a fortnight's work. Thanks.
Jon Hurst is offline   Reply With Quote
Old 01-18-2013, 02:35 PM   #30
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,316
Karma: 4963983
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
There was a problem with links in Windows, I think it's fixed in version 1.4.
Jellby is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 09:34 PM.


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