![]() |
#1 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30
Karma: 4698
Join Date: Jan 2011
Device: none
|
Converting PDF with code samples - losing battle?
I just downloaded the latest Calibre update released today. And I have tried converting some programming books in PDF format with this new version as well the previous version before this. The problem I have is that the sample code listings are mangled or re-flown during conversion to epub.
I even downloaded Sigil to see if it was something I could fix manually. But it seems like Calibre is outputting the code in a <p> tag with "calibre2" style applied just like the rest of the book. Meaning it is too late for Sigil to do anything. I also noticed that the page headers are not being removed correctly so I have unnecessary page breaks (and page numbers and text). However, there are options in Calibre to specify a regex. So it's only a matter of (!) learning the right regex and putting it in there. But if there is no way to fix the code listing problem then I'd rather not waste my time on this. I noticed that every listing in the PDF begins with a header with text "Listing 1.1". I am not sure if there is a way to specify the regex for inserting a <Pre> tag at these places. Save for these two issues with PDF's, the tool works like a charm. So a grateful thanks to the author kovid. I used it to convert a .CHM with code listings and all to epub. So if it understood that, there's gotta be a way to make it understand this. |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,190
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30
Karma: 4698
Join Date: Jan 2011
Device: none
|
Thanks kovid. I saw it already from another thread. Did not help.
|
![]() |
![]() |
![]() |
#4 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30
Karma: 4698
Join Date: Jan 2011
Device: none
|
Interesting... I just found pdfonline.com and gave it my PDF. It butchered the TOC and did some slightly funky formatting but kept the code samples intact. The conversion timed out so it only gave me a partial document back. I did not bother to check the length as I was more interested in the formatting anyway.
I then gave the rtf to Calibre and it kept the code formatted correctly! The funky formatting got funkier and headers were shown as text too. Overall, its unusable, but the code was transferred correctly. Just sharing! |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
losing line spacing when converting with Calibre | Stensie4JC | Conversion | 9 | 01-23-2011 03:47 PM |
Amazon losing the e-book pricing battle: Will content trump distribution? | kjk | News | 0 | 02-05-2010 11:32 AM |
Losing formatting when converting PDB | Edwin Fong | Calibre | 5 | 10-25-2009 07:20 PM |
PDF samples | kovidgoyal | Calibre | 13 | 09-23-2009 06:40 AM |
Losing chapter information when converting | pars_andy | Calibre | 3 | 04-25-2009 02:55 PM |