Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 11-06-2022, 10:51 PM   #1
lysakowski
Junior Member
lysakowski began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2015
Location: Boston area
Device: Adobe Acrobat, iPad 2, Android Phone, Windows 10
Unhappy 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.
Attached Thumbnails
Click image for larger version

Name:	Calibre-ePub-to-PDF-converter-output-settings-do-not-work.png
Views:	145
Size:	63.8 KB
ID:	197575  
lysakowski is offline   Reply With Quote
Old 11-06-2022, 11:38 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: 44,027
Karma: 22669822
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.
kovidgoyal is offline   Reply With Quote
Advert
Old 11-09-2022, 02:06 PM   #3
lysakowski
Junior Member
lysakowski began at the beginning.
 
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.
lysakowski is offline   Reply With Quote
Old 11-09-2022, 02:15 PM   #4
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 36,896
Karma: 147879470
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 02:17 PM.
DNSB is offline   Reply With Quote
Old 11-09-2022, 02:16 PM   #5
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,694
Karma: 26966376
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 03:33 PM.
BetterRed is offline   Reply With Quote
Advert
Old 11-09-2022, 03:09 PM   #6
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,990
Karma: 56143932
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
theducks is offline   Reply With Quote
Old 11-09-2022, 06:41 PM   #7
lysakowski
Junior Member
lysakowski began at the beginning.
 
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
lysakowski is offline   Reply With Quote
Old 11-09-2022, 09:10 PM   #8
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,694
Karma: 26966376
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by lysakowski View Post

@BetterRed, Do you mean that the change applies to ALL CONVERTERS, or just the ePub to PDF converter?
Yes - because the Font size rescaling switch is in Common Options, it would be applied to all appropriate conversions - format specific settings are in the format specific Input and Output sections.

BR
BetterRed is offline   Reply With Quote
Old 04-29-2023, 09:11 PM   #9
lysakowski
Junior Member
lysakowski began at the beginning.
 
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:
Originally Posted by kovidgoyal View Post
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.
I want font size rescaling to work only on the <pre> tags for Python code.

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?
lysakowski is offline   Reply With Quote
Old 04-30-2023, 05:44 AM   #10
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,710
Karma: 87663463
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
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.
Quoth is offline   Reply With Quote
Reply

Tags
epub-to-pdf, pdf-output, python-output


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Python 2 to Python 3, Polyglot & Plugins DaltonST Calibre 18 04-24-2019 12:10 AM
3.34 calibre-debug runs the script code under Python 3 EbokJunkie Conversion 2 11-20-2018 07:43 PM
Calibre Python code for fetching by asin/googleid plo233 Development 6 11-16-2018 06:16 AM
Python error when converting epub to epub Superbra Calibre 5 05-27-2018 06:25 AM
python coding... alexxxm Sony Reader 8 01-31-2008 12:25 PM


All times are GMT -4. The time now is 06:44 AM.


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