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 05-29-2013, 06:00 PM   #1
dancal
Member
dancal began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Dec 2012
Device: PC
calibre EPUB->PDF: page numbers in printed TOC?

Hi, I'm converting EPUB -> PDF for printing. I got the page numbers in the footer and in the PDF bookmars, but those are useless once the book is printed. I want the page numbers in the printed TOC. Is there a way to achieve this?

Failing that is there an external tool to convert the bookmarks to a printable TOC with page numbers (so I could print that separately?)

(by the way, why isn't there a "Generic printed book" output profile?)

-- Dan
dancal is offline   Reply With Quote
Old 05-29-2013, 10:07 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: 25,673
Karma: 4998489
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There's no way to do that, adding an option to auto-generate a toc based on the outline is on my TODO list, but it is a fairly complex task so I dont know when, or if, I will ever get around to it. Patches are welcome.
kovidgoyal is offline   Reply With Quote
 
Enthusiast
Old 05-29-2013, 11:06 PM   #3
dancal
Member
dancal began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Dec 2012
Device: PC
This has got to be pretty easy though. I can extract the "outline" (bookmarks) with jpdfbookmarks and print that as a separate text file.

Surely since calibre generates the PDF bookmarks, it could also include the pages in the TOC it generates at the beginning of the PDF (along with the hyperlinks, which become useless once printed)?
dancal is offline   Reply With Quote
Old 05-29-2013, 11:17 PM   #4
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: 25,673
Karma: 4998489
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by dancal View Post
This has got to be pretty easy though.
Then feel free to submit a patch, and you will learn exactly why it is not so easy.
kovidgoyal is offline   Reply With Quote
Old 05-29-2013, 11:31 PM   #5
dancal
Member
dancal began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Dec 2012
Device: PC
It's not such friendly software to hack into. I've lifted small bits out of it before, but it wasn't a pleasant experience. My feeling is that it tends to over-abstract, at multiple levels, which is why some simple things become extremely hard, and why you repeatedly refuse to implement some features without giving any technical explanation. They just don't fit the abstraction that was adopted early in the beginning, and changing that abstraction is impossible because there's another abstraction on top of it.

Bottom line, I believe you, and it's unfortunate you didn't implement things differently.
dancal is offline   Reply With Quote
Old 05-29-2013, 11:41 PM   #6
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: 25,673
Karma: 4998489
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
What rot. You have no freaking clue what you are talking about. Your lack of ability has absolutely no bearing on calibre's code quality.

Bottom line: You're lazy and you resort to whining to try to cover that up.
kovidgoyal is offline   Reply With Quote
Old 05-29-2013, 11:53 PM   #7
dancal
Member
dancal began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Dec 2012
Device: PC
Either it's easy and your post #4 is a lie, or it's not so easy and your post #6 is an unjustified ad-hominem attack. Make up your mind.

I was hinting at Joel Spolsky's Law of Leaky Abstractions (http://www.joelonsoftware.com/articl...tractions.html). When you have to dig around 8-9 different files / classes to reach the bottom of a simple feature (the place where the core of that feature is actually implemented) it's likely that there is a bit of over-abstracting going on. And it's also rational for anyone not to waste time again trying to reverse-engineer the convoluted design of calibre.

Since the problem is so clear to you, you could have said "look at source /path/to/x.py". Why should someone else waste time tracking down something that you know off the top of your head? Software doesn't need to read like a puzzle.

Last edited by dancal; 05-29-2013 at 11:56 PM.
dancal is offline   Reply With Quote
Old 05-30-2013, 12:03 AM   #8
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: 25,673
Karma: 4998489
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Let me explain something to you: when I say something is not easy, that means the ratio of effort to interest involved in implementing it moves it off the top of my queue compared to the 3000 other things in that queue that have better effort to interest ratios.

Actually implementing this feature will take about 300 lines of code, the relevant files are all in the pdf/render/ folder and there is a grand total of five classes involved. But, I'm guessing that's too hard for you, because, as I said before, you are lazy. Or perhaps when you were a baby you were attacked by a particularly mean looking class.

And let me explain something about abstractions. All abstractions are, gasp, *leaky*, that does not mean every abstraction is bad. It is only bad if the harm from the leakiness outweighs the benefit from the, wait for it, *abstraction*.
kovidgoyal is offline   Reply With Quote
Old 05-30-2013, 01:13 AM   #9
dancal
Member
dancal began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Dec 2012
Device: PC
As a simple work-around, here's a one-liner to generate a separate TOC.pdf (which you can then prepend to the main PDF, or print):

Code:
jpdfbookmarks -p'|' -d FILE.pdf | perl -ne 'if (/(.*)\|(\d+)/) { printf "%5d  %s\n", $2, $1 }' | a2ps -B -1 -o - | ps2pdf - /tmp/TOC.pdf
Kovid, feel free to disregard my observations if they made you angry (no point in spamming others, so I won't argue any further). Whatever your feelings, I don't see why you should be calling names someone who chooses not to contribute to your open-source baby. But whatever makes you feel powerful...
dancal is offline   Reply With Quote
Old 05-30-2013, 01:19 AM   #10
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: 25,673
Karma: 4998489
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Just for your future reference:

When you ask someone to do something for you, for free, and that someone says they will get to it whenever they have the time/inclination, the appropriate response is not to malign their work. If you do, you will get *flamed*. I was positively gentle with you.
kovidgoyal is offline   Reply With Quote
Old 05-30-2013, 03:40 AM   #11
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: 25,673
Karma: 4998489
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Just to prove what I said in my previous post, here's the implementation, in less than 300 lines, including documentation and GUI.

https://github.com/kovidgoyal/calibr...cb158a2e093f99
kovidgoyal is offline   Reply With Quote
Old 06-08-2013, 03:33 PM   #12
dancal
Member
dancal began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Dec 2012
Device: PC
I did not *ask* you to do anything for free. I tried to *shame* you into doing something that should have been done a long time ago -- and I guess it worked. Thanks, by the way. As I've posted I've solved my problem with a one-line script though,.

I guess this was indeed not a case of leaky abstractions -- but that doesn't mean your baby doesn't suffer from it.

Feel free to insult me some more -- it won't do you or me any good of course.

Last edited by dancal; 06-08-2013 at 03:38 PM.
dancal is offline   Reply With Quote
Old 06-08-2013, 09:49 PM   #13
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: 25,673
Karma: 4998489
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by dancal View Post
I did not *ask* you to do anything for free. I tried to *shame* you into doing something that should have been done a long time ago.
You really are toxic little man, aren't you.

Quote:
-- and I guess it worked. Thanks, by the way. As I've posted I've solved my problem with a one-line script though.
A one line script that uses thousands of lines of code from another software project, impressive.

Quote:
I guess this was indeed not a case of leaky abstractions -- but that doesn't mean your baby doesn't suffer from it.
Of course it does, because, you say so, and as this thread has amply demonstrated, you certainly know what you're talking about.

Quote:
Feel free to insult me some more -- it won't do you or me any good of course.
Happy to oblige.

>/dev/null
kovidgoyal is offline   Reply With Quote
Old 06-13-2013, 08:32 PM   #14
dancal
Member
dancal began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Dec 2012
Device: PC
Sorry for the flame war. It was not warranted.

Your project also uses 1000's of lines from other projects, right? That's how libraries work (but I prefer the arms-length separation that the CLI requires).

We've had dealings in the past. Remember that annoying "Not going to happen" comment? You are a pretty obnoxious individual yourself.
dancal 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
Kindle (AZW3/MOBI) ebooks with "real page numbers" to PDF with same page numbers? abvgd Conversion 2 05-24-2013 01:24 PM
Calibre: convert to PDF with page numbers HagaWaga Calibre 6 01-30-2013 10:46 AM
pdf (with page numbers) to epub crill Workshop 12 05-30-2012 02:16 PM
Calibre getting page numbers wrong in conversion to epub. WendyH Conversion 9 09-04-2011 05:29 AM
ePub TOC page not detected by Calibre on convert chyron8472 Conversion 4 03-11-2011 05:10 PM


All times are GMT -4. The time now is 11:20 AM.


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