![]() |
#1 |
Member
![]() 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 |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,199
Karma: 27110894
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.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Member
![]() 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)? |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,199
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
![]() |
![]() |
![]() |
#5 |
Member
![]() 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. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,199
Karma: 27110894
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. |
![]() |
![]() |
![]() |
#7 |
Member
![]() 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. |
![]() |
![]() |
![]() |
#8 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,199
Karma: 27110894
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*. |
![]() |
![]() |
![]() |
#9 |
Member
![]() 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 |
![]() |
![]() |
![]() |
#10 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,199
Karma: 27110894
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. |
![]() |
![]() |
![]() |
#11 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,199
Karma: 27110894
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 |
![]() |
![]() |
![]() |
#12 |
Member
![]() 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. |
![]() |
![]() |
![]() |
#13 | ||||
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,199
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Quote:
Quote:
Quote:
![]() Quote:
>/dev/null |
||||
![]() |
![]() |
![]() |
#14 |
Member
![]() 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. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
pdf (with page numbers) to epub | crill | Workshop | 13 | 01-12-2019 09:13 AM |
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 |
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 |