Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 10-13-2021, 01:57 PM   #1
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,273
Karma: 4155811
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Question Bug in Calibre Viewer?

The attached epub has a little script that modifies the body margins of the ebook. It works flawlesly with the Calibre Ebook Editor, but in Calibre Viewer has an issue; once the epub is loaded, margins are not simetrical.

With the Viewer Inspector I was able to see that the issue is originated by the property "width" (for the element Body) added by Calibre. I tried a workaround by setting the property "width: auto" for Body (that disables the "width" added by Calibre), but that generated others problems (collisions with the properties "column-gap" and "column-width" added by Calibre, I think) and only the first page is showed correctly. So, my question is: how must I do in order that, if I modify margins with a script, Calibre Viewer shows them properly?

Many thanks in advance.
Attached Files
File Type: epub MarginsTestCase.epub (3.4 KB, 12 views)
RbnJrg is offline   Reply With Quote
Old 10-13-2021, 10:05 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: 39,816
Karma: 17764952
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You cannot change margins in paged mode. Margins in paged mode are created by CSS3 columns. You could in theory change the CSS the viewer uses for that, but it will break many things.
kovidgoyal is offline   Reply With Quote
Old 10-14-2021, 09:15 AM   #3
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,273
Karma: 4155811
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by kovidgoyal View Post
You cannot change margins in paged mode. Margins in paged mode are created by CSS3 columns. You could in theory change the CSS the viewer uses for that, but it will break many things.
Hi Kovid;

Thanks for your answer, just one more question: I was able to see that Viewer, in paged mode, when we set margins by hand, by means of "Preferences", the properties "width" and "column-width" are equals and the property "column-gap" is equal to left-margin plus right margin (and column-width + column-gap = window.innerWidth). Of that way, for example if I want a margins (left and right) of 50px, and I have a window.innerWidth of 500px, by setting a "width:400px", "column-width:400px" and "column-gap:100px", in theory it should work. But it doesn't When I modified by hand, with the Viewer Inspector, the values of "width", "column-width" and "column-gap", or the Viewer enters in scroll-mode, or margins are asimetrical. So, are there others variables involved besides width, column-width and column-gap? Many thanks in advance.
RbnJrg is offline   Reply With Quote
Old 10-14-2021, 10:37 AM   #4
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: 39,816
Karma: 17764952
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Read the source code, its in paged_mode.pyj, the layout() function.
kovidgoyal is offline   Reply With Quote
Old 10-14-2021, 02:33 PM   #5
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,273
Karma: 4155811
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by kovidgoyal View Post
Read the source code, its in paged_mode.pyj, the layout() function.
Thanks!
RbnJrg is offline   Reply With Quote
Old 10-16-2021, 02:08 PM   #6
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,273
Karma: 4155811
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Sorry for bother you, Kovid. I was able to find a way to employ custom margins with Calibre Viewer in paged mode. In fact, I could find TWO ways, but the last one has an inconvenience that, so far, I was not able to fix.

If you open MarginsTestCase-ONE with Calibre Viewer, you'll see that your program can display pages without issues, in spite of the epub has custom margins, modified by a script. To get that, I enclosed all the content in a div wrapper and I applied margins to it. Probably, this is the most economic way to get custom margins with Calibre Viewer.

Now, if you open MarginsTestCase-TWO, you'll see a totally different script to apply custom margins. This script takes into account, the current values managed for Viewer for width, column-width and column-gap. And it calculates the new margins according to those previous values. And it works fine, except for the last paragraph of any .xhtml file.

Click image for larger version

Name:	Image1.png
Views:	10
Size:	47.7 KB
ID:	189664Click image for larger version

Name:	Image2.png
Views:	8
Size:	47.8 KB
ID:	189665Click image for larger version

Name:	Image3.png
Views:	8
Size:	47.9 KB
ID:	189666Click image for larger version

Name:	Image4.png
Views:	9
Size:	40.2 KB
ID:	189667

Evidently I need to modify another more parameter of the Viewer to fix that, but I couldn't locate it in your layout() function. Could you tell me, according to your experience and since you are the creator and the developer of Calibre, what do you think I have to modify, to fix that bleeding of the last pages? Thank you very much in advance.
Attached Files
File Type: epub MarginsTestCase-ONE.epub (4.3 KB, 8 views)
File Type: epub MarginsTestCase-TWO.epub (4.6 KB, 2 views)
RbnJrg is offline   Reply With Quote
Old 10-16-2021, 10:59 PM   #7
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: 39,816
Karma: 17764952
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You really shouldnt be doing this at all. How margins are implemented in the viewer is an internal detail. Trying to script it could well break badly if those internal details change in the future. There is no guarantee that those details will remain the same in the future.
kovidgoyal is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bug with Mobi and Calibre Viewer JSWolf Calibre 2 08-15-2019 06:31 AM
BUG: Calibre 2.0 E-Book Viewer ePub extra space display problem trying Calibre 3 08-28-2014 07:56 AM
Possible viewer bug? itimpi Library Management 19 05-13-2014 12:29 PM
Calibre: eBook Viewer - CSS Bug navjot001 Library Management 1 03-25-2014 08:55 AM
bug ? calibre epub viewer shows old title cybmole Calibre 11 03-03-2011 10:26 AM


All times are GMT -4. The time now is 11:05 AM.


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