|
|
Thread Tools | Search this Thread |
11-06-2022, 11:51 PM | #1 |
Junior Member
Posts: 9
Karma: 10
Join Date: Feb 2015
Location: Boston area
Device: Adobe Acrobat, iPad 2, Android Phone, Windows 10
|
Converting ePub Python coding books to PDF outputs Python code far too small
I have a lot of Python programming books in ePub format, and I need to convert them to PDF format.
The ePub to PDF conversion process is generally very good. I like the fact that a good, navigable TOC is generated in the PDF. The recurring problem is that Python code output in the converted file is always TOO SMALL. It is often SO small that the Python code is unusable, hence I just throw it away and try the conversion gain. Occasionally the PDF output conversion works, but not reliably. It seems to depend on the individual ePub book. I need the code and non-code text to remain the same RELATIVE size as in the ePub format. I have tried setting the "Monospace font size" output at every value from 14 to 24-point size with the Default size to 12 px. This does not seem to have any impact on upsizing the Python code font, while upsizing the text. I have read the conversion documentation several times, but do not find any mention of how to control programming language code sizing for conversion outputs. What can people recommend to fix this problem? It would be great if there were separate tags for code in a book, like the <pre> tag used to encode Python code on HTML pages. |
11-07-2022, 12:38 AM | #2 |
creator of calibre
Posts: 44,653
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
there is no such thing as "programming language code size". You need to figure out what CSS is used for your code samples in the epub files, and adjust the font size key in the conversion settings accordingly or just turn off font size rescaling, then conversion will not touch your font sizes.
|
Advert | |
|
11-09-2022, 03:06 PM | #3 |
Junior Member
Posts: 9
Karma: 10
Join Date: Feb 2015
Location: Boston area
Device: Adobe Acrobat, iPad 2, Android Phone, Windows 10
|
Thank you for your reply. Calibre is a fabulous contribution !
How do I turn off Font Size Rescaling for the ePub to PDF conversion process in Calibre? That seems like the simplest way, before looking into changing CSS code. |
11-09-2022, 03:15 PM | #4 |
Bibliophagist
Posts: 41,299
Karma: 158182188
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Open calibre. Preferences => Conversion => Common Options => Look & feel under the Fonts tab. Check Disable font size rescaling.
You may also want to play with some of the PDF setting in Output options. However, converting to PDF is not great though much better than converting from PDF. Last edited by DNSB; 11-09-2022 at 03:17 PM. |
11-09-2022, 03:16 PM | #5 |
null operator (he/him)
Posts: 21,114
Karma: 27620706
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
It's also in Conversion->Look & Feel->Fonts
If you set it in Preferences it will apply to ALL conversions, which may have unintended consequences. BR Last edited by BetterRed; 11-09-2022 at 04:33 PM. |
Advert | |
|
11-09-2022, 04:09 PM | #6 |
Well trained by Cats
Posts: 30,506
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Note
Preferences... is the default for the first conversion of that book Conversion... is where you THEN override the previous conversions of that book. Also note there is a tick or button to make (selected) Conversions forget PREVIOUSLY USED settings and grab a fresh default |
11-09-2022, 07:41 PM | #7 |
Junior Member
Posts: 9
Karma: 10
Join Date: Feb 2015
Location: Boston area
Device: Adobe Acrobat, iPad 2, Android Phone, Windows 10
|
Thank you for the answers. Disabling font size rescaling appears fixed the problem of making the Python code font smaller font.
It looks like part of the problem is the source ePub files themselves. Many ePub books use a font face for Python-highlighted code that is smaller than the surrounding (non-highlighted) text, making it harder to read. It would be nice if I could actually INCREASE Python highlighted code font size 1-2 points, to improve the readability of the PDF over the original ePub. Does anyone have any examples of how to accomplish this, i.e., selectively increase the output of specific styles of text? It looks like the publishers are using <pre> tags or pygments package for rending the code. I will open the ePub in the Editor to see if I can find the CSS code for highlighted Python. @BetterRed, Do you mean that the change applies to ALL CONVERTERS, or just the ePub to PDF converter? @theducks, where is the tick or button to make Conversions "forget previously used settings"? This is what I want when I am tuning the conversion process. I don't want to have to make the change every time I do a conversion, because I may not remember the settings that result in a good conversion. Also, I would like to be able to give the converted file a different name so that I can distinguish my conversion process trial runs from one another. Thanks guys. I will report back when I get a working solution. Richard |
11-09-2022, 10:10 PM | #8 | |
null operator (he/him)
Posts: 21,114
Karma: 27620706
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
BR |
|
04-29-2023, 10:11 PM | #9 | |
Junior Member
Posts: 9
Karma: 10
Join Date: Feb 2015
Location: Boston area
Device: Adobe Acrobat, iPad 2, Android Phone, Windows 10
|
Changing PDF output converter CSS settings for Python code that is too small
Quote:
I am starting to understand how to do this font size adjustment during conversion. If I add some extra CSS for the <pre> tag in the field in "Look & Feel" ... "Styling"... "Extra CSS", I can adjust the font size and padding. I have to experiment with it some more to get the result I want. I don't know much about CSS specifics yet, whether to use font-size in pixels, rem units, vmin units, or something else. Is there a separate converter package in the Calibre package for this conversion functionality? Once I figure out the correct conversion CSS settings, I want to do a bulk conversion of epub files to PDF files, because it is too tedious to do it one publication at a time. I would like to feed in the conversion CSS output specs as a template. Also, in the Convert dialog box, is there a place to specify the name of the output file? The Calibre PDF output converter currently truncates the filename to 35 characters. I would like to be able to specify the output when using Calibre to manage the conversion. Will the changed output filename from the conversion process get picked up by the Calibre Indexing Engine, or the next time Calibre starts up? |
|
04-30-2023, 06:44 AM | #10 |
Reading till the spring
Posts: 12,519
Karma: 94058919
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
font-size is best in em, 1em is a standard size for body text. Usually renderers assume 12pt = 1em exactly, so mostly pt also works. Never use pixels, rem, or physical size for font-size.
Note different font families can be larger or smaller than say Times Roman at the same size. Also different similar fonts (serif, sans, monospace, etc) can be a different size at same size setting. There are loads of different monospace (AKA typewriter or console) fonts suitable for displaying/rendering code. |
Tags |
epub-to-pdf, pdf-output, python-output |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Python 2 to Python 3, Polyglot & Plugins | DaltonST | Calibre | 18 | 04-24-2019 01:10 AM |
3.34 calibre-debug runs the script code under Python 3 | EbokJunkie | Conversion | 2 | 11-20-2018 08:43 PM |
Calibre Python code for fetching by asin/googleid | plo233 | Development | 6 | 11-16-2018 07:16 AM |
Python error when converting epub to epub | Superbra | Calibre | 5 | 05-27-2018 07:25 AM |
python coding... | alexxxm | Sony Reader | 8 | 01-31-2008 01:25 PM |