Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 03-01-2018, 01:23 AM   #1
teresatenured
Junior Member
teresatenured began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Mar 2018
Device: Kindle 4th Gen
Add page breaks in Calibre

My Kindle (Paperwhite, 4th Gen) has broken . Half of the screen is 'blurred' with vertical lines, and is totally unresponsive. Tried to hard reset, no luck. Luckily, the top half of the screen (6.5 cm) works.

I am trying to make some use of it before I finally chuck it. I looked into swapping out the Kindle screen, but after some research it doesnt seem feasible. Rather, id like to format my Ebooks to make them readable on my defunct Kindle. I can see about 600 contiguous characters of text on the screen. Then the letters start to blur.

So id like to make it so that each kindle page only shows 600 characters. After 600 characters, I would like to insert a page break. Then after 600 more characters, another page break. I would like to do this for all my books, so that they will be readable on my broken Kindle.

Any Ideas on how to add page breaks, either in Calibre or Word or Acrobat? I've had some success adding page breaks on a short document in Word, but I had to literally count 600 characters and then click 'Insert Page Break'. The document was readable on my Kindle, but it would not be feasible to do this for a whole book.

TLDR; Kindle broke; want to add page breaks to my books after each 600 characters of text.

Thanks!

Last edited by teresatenured; 03-01-2018 at 01:31 AM.
teresatenured is offline   Reply With Quote
Old 03-01-2018, 07:09 PM   #2
FizzyWater
You kids get off my lawn!
FizzyWater ought to be getting tired of karma fortunes by now.FizzyWater ought to be getting tired of karma fortunes by now.FizzyWater ought to be getting tired of karma fortunes by now.FizzyWater ought to be getting tired of karma fortunes by now.FizzyWater ought to be getting tired of karma fortunes by now.FizzyWater ought to be getting tired of karma fortunes by now.FizzyWater ought to be getting tired of karma fortunes by now.FizzyWater ought to be getting tired of karma fortunes by now.FizzyWater ought to be getting tired of karma fortunes by now.FizzyWater ought to be getting tired of karma fortunes by now.FizzyWater ought to be getting tired of karma fortunes by now.
 
FizzyWater's Avatar
 
Posts: 4,220
Karma: 73492664
Join Date: Aug 2007
Location: Columbus, Ohio
Device: Oasis 2 and Libra H2O and half a dozen older models I can't let go of
Could you experiment with creating a large bottom margin and converting the book in Calibre with the new margins? I'm at work, or I'd test this idea before posting.
FizzyWater is offline   Reply With Quote
Advert
Old 03-01-2018, 08:00 PM   #3
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
Copy and paste the following line after every 600 characters;

<p class="chapter"><p>

Add the following to your .css file:

.chapter {
display: block;
margin: 3em 0;
page-break-after: always;
}

I would also combine all the html files that contain the text into one html file (right-click and choose merge files).

Then convert the file. Calibre will split the "text" html file into a bunch of html files, beginning with each of the <p class="chapter"></p> lines (the class "chapter" alerts conversion to split the file at that point). You really don't need the page-break-after: always; line in the .css file, but it won't hurt to include it. Conversion will delete that line during the conversion.

Last edited by deback; 03-01-2018 at 08:16 PM.
deback is offline   Reply With Quote
Old 03-01-2018, 08:06 PM   #4
sjfan
Addict
sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.
 
Posts: 281
Karma: 7724454
Join Date: Sep 2017
Location: Bethesda, MD, USA
Device: Kobo Aura H20, Kobo Clara HD
Quote:
Originally Posted by teresatenured View Post
My Kindle (Paperwhite, 4th Gen) has broken . Half of the screen is 'blurred' with vertical lines, and is totally unresponsive. Tried to hard reset, no luck. Luckily, the top half of the screen (6.5 cm) works.

I am trying to make some use of it before I finally chuck it. I looked into swapping out the Kindle screen, but after some research it doesnt seem feasible. Rather, id like to format my Ebooks to make them readable on my defunct Kindle. I can see about 600 contiguous characters of text on the screen. Then the letters start to blur.

So id like to make it so that each kindle page only shows 600 characters. After 600 characters, I would like to insert a page break. Then after 600 more characters, another page break. I would like to do this for all my books, so that they will be readable on my broken Kindle.

Any Ideas on how to add page breaks, either in Calibre or Word or Acrobat? I've had some success adding page breaks on a short document in Word, but I had to literally count 600 characters and then click 'Insert Page Break'. The document was readable on my Kindle, but it would not be feasible to do this for a whole book.

TLDR; Kindle broke; want to add page breaks to my books after each 600 characters of text.

Thanks!
For a proper solution you'd want a true parser, but you can do something quick and dirty with regexes. If all your body paragraphs are class="para", for instance:

In Calibre's editor, regex search for:
Code:
(?ms)(.{600}.*?)<p class="para">
Replace with:
Code:
\1<p class="para break">
And make sure the "break" style has "page-break-before: always" set.

This will search for 600 characters (but includes code characters as well as displayed text), and then find the next <p class="para"> and turn it into a para/break tag. The ? here is to make the prior expression non-greedy, so you find the shortest possible distance to the next tag (regexes default to longest possible).

If things are heavily marked up it won't be very accurate, and you may want to dial it down to 500 or so because it looks ahead for the next paragraph after the 600 characters are up (rather than creating a new paragraph break mid-paragraph).

Or you could use "\. " instead of the '<p class="para">' search (untested, but something like that) and do a replace of
Code:
\1. <div class="break"></div>
if you want to insert hard breaks mid paragraph. You have to be kind of careful selecting the search regex here so you don't break in the middle of an HTML tag.
sjfan is offline   Reply With Quote
Old 03-01-2018, 11:44 PM   #5
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
Hmm, how about using Print to PDF via Calibre Viewer? Say B6 paper size with a large bottom margin?
ilovejedd is offline   Reply With Quote
Advert
Old 03-02-2018, 12:33 AM   #6
teresatenured
Junior Member
teresatenured began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Mar 2018
Device: Kindle 4th Gen
FizzyWater - That's a good idea! I'm not sure how I would do that though. Any Ideas?

deback - There's absolutely no way I'm counting 600 characters manually for a whole book. I might as well just read it on the Calibre editor at that point.

sjfan - Good Ideas; unfortunately neither of your methods worked. One thing I noticed was that all the body-paragraphs are class="indent" . So I tried

Code:
(?ms)(.{400}.*?)<p class="indent">
and replaced with

Code:
\1<p class="para break">
The editor said it made 400ish changes, but I did not see any effect when I uploaded it to my Kindle.

Your second replacement method (\.) did produce some changes, but not anything desirable. Some of the document was formatted as the original, while seemingly every other paragraph was randomly centered and indented. And still the EBook was displayed on the full screen of the Kindle, instead of only the top half the screen.

This was just one book, and maybe it would be different with others, but unfortunately it did not work. Thanks for the effort though! Any other ideas?
teresatenured is offline   Reply With Quote
Old 03-02-2018, 12:52 AM   #7
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
You need to define "para break" in the CSS to get it to do something.

If you want to skip all that, using <p class="chapter"><p> as recommended by deback should do the trick.

This is what I'd do:

Search
Code:
(?ms)(.{400}.*?)(<p[ >])
Replace
Code:
\1<div class="chapter"></div>\2
The \1 and \2 corresponds to the search matches inside the parentheses:
Code:
\1: .{400}.*?
\2: <p[ >]
The above replacement regex basically inserts <div class="chapter"></div> between \1 and \2, and should match any paragraph regardless of class or style. Then convert via Calibre with Structure detection - Chapter mark - pagebreak.

Last edited by ilovejedd; 03-02-2018 at 12:57 AM.
ilovejedd is offline   Reply With Quote
Old 03-02-2018, 02:01 AM   #8
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
If we were talking about an epub reader, I would suggest using the @page CSS rule. With that, you could set the bottom margin if the page to whatever was needed to prevent anything from being displayed in the bad section of the screen. Something like the following would probably work:

Code:
@page {
   margin-bottom: 3cm
}
With appropriate testing of how much to set the bottom margin. And I have no idea whether cm works as a margin here.

I don't use a Kindle, so I don't know what would happen if you converted an epub that has the above to a Kindle suitable format.
davidfor is offline   Reply With Quote
Old 03-02-2018, 02:43 AM   #9
sjfan
Addict
sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.sjfan ought to be getting tired of karma fortunes by now.
 
Posts: 281
Karma: 7724454
Join Date: Sep 2017
Location: Bethesda, MD, USA
Device: Kobo Aura H20, Kobo Clara HD
Quote:
Originally Posted by teresatenured View Post
FizzyWater - That's a good idea! I'm not sure how I would do that though. Any Ideas?

deback - There's absolutely no way I'm counting 600 characters manually for a whole book. I might as well just read it on the Calibre editor at that point.

sjfan - Good Ideas; unfortunately neither of your methods worked. One thing I noticed was that all the body-paragraphs are class="indent" . So I tried

Code:
(?ms)(.{400}.*?)<p class="indent">
and replaced with

Code:
\1<p class="para break">
The editor said it made 400ish changes, but I did not see any effect when I uploaded it to my Kindle.
First, davidfor's idea of setting the @page margin is probably the best idea if it works.

Second, did you do this as well like I said? And make sure the "break" style has "page-break-before: always" set.

Just adding a non-existent "break" style isn't going to do anything; you need to define that style in the CSS to insert the breaks.

Also, you don't want to rewrite your indent style to a nonexistent para. The replace-with should be
Code:
\1<p class="indent break">
in your case.
sjfan is offline   Reply With Quote
Old 03-02-2018, 03:15 AM   #10
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: 43,844
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you want to set margins, you can do it via the Page setup section of the conversion dialog.
kovidgoyal is offline   Reply With Quote
Old 03-02-2018, 03:33 AM   #11
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,897
Karma: 128597114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
If you can afford it, I suggest buying a new Reader.
JSWolf is offline   Reply With Quote
Old 03-02-2018, 04:09 AM   #12
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by kovidgoyal View Post
If you want to set margins, you can do it via the Page setup section of the conversion dialog.
And I remembered that about 10 minutes after I made my post.
davidfor is offline   Reply With Quote
Old 03-02-2018, 07:23 PM   #13
teresatenured
Junior Member
teresatenured began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Mar 2018
Device: Kindle 4th Gen
sjfan - Sorry, i should have mentioned that I'm pretty dumb when it comes to anything computer related. Where would I even add

"And make sure the "break" style has "page-break-before: always" set."?

ilovejedd - You are amazing ! A solution that even I could figure it out. It worked for some of the books I've tried, but not all. Even when it works though, some of the longer paragraphs bleed into the broken part of the screen. I tried playing with the values (300, 350, etc), but still. I don't have any insight into why this happens though.

and what do I do with this?

Code:
\1: .{400}.*?
\2: <p[ >]
Either way - You Rock!!

davidfor, kovidgoyal - Thanks for the response. I have relatively limited experience with CSS but I did try editing the margins with @page (in pixels). I saw no change. As well, when I edited the margins via Page Setup, i could only increase the bottom margin up to 200 pixels. I tried this, but because the text still bled into the broken portion of the screen, I could not tell if it made a difference. Thanks for the effort though!
teresatenured is offline   Reply With Quote
Old 03-02-2018, 09:48 PM   #14
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
Quote:
Originally Posted by teresatenured View Post
and what do I do with this?

Code:
\1: .{400}.*?
\2: <p[ >]
Either way - You Rock!!
Nothing. That's just a more visual guide of what the \1 and \2 in the regex replace code corresponded to.

And you're welcome.
ilovejedd is offline   Reply With Quote
Reply

Tags
calibre, delimiters, kindle, page break


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre unwanted page breaks ebookscovers Conversion 20 05-03-2017 02:10 PM
MOBI to EPUB conversion in calibre adds page breaks waynn Conversion 15 04-05-2017 03:05 PM
Mobi page breaks in Calibre viewer DaleDe Calibre 3 04-04-2011 01:58 AM
Adding page breaks in Calibre breaks ePubcheck validation bookraft Conversion 16 03-01-2011 01:23 PM
Force Calibre not to add Page Breaks on H1 and H2 Tags jloakes Calibre 2 11-18-2010 04:08 PM


All times are GMT -4. The time now is 09:43 PM.


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