05-23-2018, 12:38 PM | #1 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
About ePub > PDF conversion
Hi
I have used for a long time the Prince PDF plugin. I have been very favorably impressed by the quality of Calibre ePub-to-PDF conversion. I have some questions. 1- the PDF produced by Calibre does not hyphen the text (and the hyphenation is not explicity forbidden or limited in the html). Though it does not seem to be important for English texts, it can give sometimes an irregular aspect to the display of text when it's written in languages which use lots of long words. Can hyphenation be added (even as an option)? 2- the size of the output PDF is amazingly compact. I can only match it with Prince if I use cpdf for "squeezing" further the PDF. How do you compress the output PDF? 3- Once the exact settings have been found (which requires some tries), it would be nice if we could save the output profile somewhere. One can imagine that we may use several kinds of PDF, one for each ebook-reader size. Maybe I am misled, but I did not find such an option. Even repeating the same conversion is no small feat. As it seems that Calibre fails to keep faithfully the last settings, the user has to remember several values scattered among several screens. 4- About conversion itself, I noticed two minor points: a- drop-caps over two lines are not converted correctly (Calibre displays them on the ePub OK) Drop-caps over three lines are OK everywhere. b- some full page images are converted with the wrong margins (Calibre displays them on the ePub OK). The latter case may be due to the fact that I did not find the right setting (?). The cover image uses exactly the same code and is perfectly displayed (with margin 0). Other images inside the text, alone in their own file, with exactly the same code, fail to display with margin 0. I can provide you with the source ePub. Last edited by roger64; 05-23-2018 at 04:56 PM. |
05-23-2018, 11:01 PM | #2 |
creator of calibre
Posts: 44,336
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
1. Sure it is easy to do, open a bug for it
2. It does not do anythong to compress, it simply has a very efficiently designed PDF backend that I wrote from scratch. 3. All calibre conversion settings are saved. https://manual.calibre-ebook.com/conversion.html (see the section on how settings are saved) 4. THere is no way to gruarantee "correct" conversion of a dropcaps, just as there is no way to guarantee correct display of one. It depends on the font size/dpi/other css settings, you will need to play with them. 5. The best way to display images with margins zero is to use the standard svg cover markup that calibre generates for its epub cover pages. That is guaranteed to work. |
05-24-2018, 03:46 AM | #3 | |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Quote:
2. thank you 3. Apologies for this. I saved indeed easily my PDF conversion preferences. 4. I'll come back on this one later. 5. About full-page images I'd like to come back on this point, because this puzzles me: when the right conversion options are ticked, Calibre converts precisely the cover image (margin 0). However, it adds margins to other images using the exact same code, even when they are isolated in their own file. Here is the very plain code (without even a reference to a stylesheet) I use. I fail to understand why it should not work for all images making use of it. Spoiler:
This code is well displayed with the ePub (with Calibre viewer too). As for PDF, I think that to allow a different treatment between the cover image and others images using exactly the same code does not seem to be right, the more so since this relative value seem to be well suited for the PDF fixed display. Last edited by roger64; 05-24-2018 at 04:20 AM. |
|
05-24-2018, 04:06 AM | #4 | ||
US Navy, Retired
Posts: 9,865
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
Quote:
Code:
<div> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" height="100%" viewBox="0 0 1200 1600" preserveAspectRatio="none"> <image width="1200" height="1600" xlink:href="cover.jpeg"/> </svg> </div> Update: I'm curious how any image with a width of 88.0% wouldn't have left and right margins? Last edited by DoctorOhh; 05-24-2018 at 04:12 AM. |
||
05-24-2018, 04:25 AM | #5 | |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Quote:
To answer your question: The image is centered. The display is fixed (this will be a PDF with 9×12 format, fit for my PW3) No margin is allowed for full-page image display (see code above). The percentage is calculated according to the shape of the image relative to a 3/4 display. I use for this a -yet- unpublished Sigil plugin. The end result is that it displays very exactly on this kind of display without any vertical margin. Obviously, due to the shape of the image, a whitespace is automatically left out on both sides (this is the result of the "auto" job). In this particular case, a 6% whitespace will appear on each side. Again, it's the consequence of the undistorted image shape, and is not related to the margins of the document. Last edited by roger64; 05-24-2018 at 04:40 AM. |
|
05-24-2018, 07:02 AM | #6 | |
US Navy, Retired
Posts: 9,865
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
Quote:
Code:
<div> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" height="100%" viewBox="0 0 1252 2024" preserveAspectRatio="xMidYMid meet"> <image width="1252" height="2024" xlink:href="cover1.jpeg"/> </svg> </div> Spoiler:
Last edited by DoctorOhh; 05-24-2018 at 07:10 PM. |
|
05-24-2018, 11:58 AM | #7 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Hi
I did some tries I used the same source ePub containing an image 606×912, size 49.5KB format jpg. I converted to PDF with Calibre using the code given above I converted to PDF with Calibre using the code for SVG images provided by the InsertImageSVG v 1.4.0 Sigil plugin. Spoiler:
These two kinds of code gave exactly the same results*. (see left screenhot1). There are document margins around the image (including vertical margins). If I convert to PDF with Prince using the code given above, (see right screenshot2). There are NO document margins around the image (only the 6% left and right due to the shape of the image). So, with Calibre, even with a svg wrapper, the display is not the one expected. The only exception with Calibre, concerns the cover image which can be displayed without document margins. Why, what can be done for the cover image could not be extended to other full page images using the same code? * Note that I do not pretend that these two codes are equivalent. If the results are the same for this particular test, it is because the first code is calculated for screens with a 3/4 ratio. There would be differences for others shapes of screen. Last edited by roger64; 05-24-2018 at 12:43 PM. |
05-24-2018, 08:41 PM | #8 | ||
US Navy, Retired
Posts: 9,865
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
Quote:
Quote:
The other option may be to print the PDF from the calibre viewer and see how that output looks. We'll see what Kovid says. |
||
05-24-2018, 10:11 PM | #9 |
creator of calibre
Posts: 44,336
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
The PDF Output in calibre does not use @page you have to set the margins to zero in the conversion settings. I've never heard of anyone creating PDF files with zero margins, they would not print very well. But, it is a trivial change to add an option to get the plugin to respect @page margins if needed.
|
05-24-2018, 10:23 PM | #10 |
creator of calibre
Posts: 44,336
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Actually, on second thoughts it is probably not a good idea to respect margins in the HTML files, that way would lead to lots of hard to debug-inconsistent rendering.
Instead probably better to just special case full page image markup, just like the viewer does. Open a bug report for it and I will get to it when I have a moment. |
05-25-2018, 02:15 AM | #11 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
When one wish to display a PDF on a small screen (say the widely used six-inch screen), the possibility to display an image really full screen makes a difference, for example for maps, drawings of all kinds. This way we extend the quality of display given to the cover image to other images of the same kind within the book.
@Kovid Goyal Thanks you very much for your interest. Bug report opened. If need be, I can provide a full ePub for testing purposes by PM. Last edited by roger64; 05-25-2018 at 03:53 AM. Reason: opened |
06-02-2018, 04:48 PM | #12 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
A short word but a big thank you to Kovid Goyal for enabling so quickly and so efficiently the two points I submitted to him about ePub-to-PDF conversion:
- hyphenation is working quite well (at least for French language) provided you tick the ad hoc check box in the Preferences page (PDF output). - Calibre can display perfectly all your full page images without document margins. To get it working, you must tick a check box in the Preferences Page PDF output (Use page margins ...) and use a svg wrapper (a compliant code -including @page 0- has been published above). To ensure that the cover image is not displayed twice (...) declare this image to be the cover_image (right click in the relevant html file). Again. Last edited by roger64; 06-02-2018 at 05:08 PM. |
06-03-2018, 12:15 AM | #13 |
creator of calibre
Posts: 44,336
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You're welcome
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Conversion PDF -> EPUB ? | JPS | Assistance | 6 | 05-19-2016 03:34 PM |
Conversion PDF -> Epub | rudmueller | Conversion | 0 | 09-11-2011 10:44 AM |
conversion from pdf to epub help | slushbilly | Workshop | 1 | 01-31-2011 08:07 AM |
PDF to EPUB Conversion | LuchoResto | General Discussions | 1 | 11-19-2010 04:54 PM |
Help with conversion from PDF to EPUB | Fizz | Calibre | 5 | 10-25-2009 11:48 AM |