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

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-19-2015, 03:06 PM   #16
JimmyR
ɴₐɴ
JimmyR ought to be getting tired of karma fortunes by now.JimmyR ought to be getting tired of karma fortunes by now.JimmyR ought to be getting tired of karma fortunes by now.JimmyR ought to be getting tired of karma fortunes by now.JimmyR ought to be getting tired of karma fortunes by now.JimmyR ought to be getting tired of karma fortunes by now.JimmyR ought to be getting tired of karma fortunes by now.JimmyR ought to be getting tired of karma fortunes by now.JimmyR ought to be getting tired of karma fortunes by now.JimmyR ought to be getting tired of karma fortunes by now.JimmyR ought to be getting tired of karma fortunes by now.
 
JimmyR's Avatar
 
Posts: 421
Karma: 2507940
Join Date: Jun 2011
Location: 37.2N 93.3W
Device: KV PW4 PW3 PW2
I've been using this in my CSS for AZW3 files on my Paperwhite:
Code:
html {
  margin-left: -16px;
  margin-right: -16px;
}
Adjust margin values to suit your needs.
JimmyR is offline   Reply With Quote
Old 01-20-2015, 05:24 AM   #17
Section8
Addict
Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.
 
Section8's Avatar
 
Posts: 254
Karma: 2092424
Join Date: Oct 2011
Location: Arlington, TX
Device: Kindle PW4, Moon+ Reader on a cheap Android tablet
Quote:
Originally Posted by JimmyR View Post
I've been using this in my CSS for AZW3 files on my Paperwhite:
Code:
html {
  margin-left: -16px;
  margin-right: -16px;
}
Adjust margin values to suit your needs.
Thank you. That's easier than what I was doing.
Section8 is offline   Reply With Quote
Advert
Old 01-22-2015, 12:10 AM   #18
pssquirrel
ebooknut
pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.
 
pssquirrel's Avatar
 
Posts: 297
Karma: 688154
Join Date: Oct 2011
Device: Kindle Voyage & Oasis
Quote:
Originally Posted by JimmyR View Post
I've been using this in my CSS for AZW3 files on my Paperwhite:
Code:
html {
  margin-left: -16px;
  margin-right: -16px;
}
Adjust margin values to suit your needs.
Curious. Negative left/right margins only work on my Voyage (5.6.1) when I set them for p, div, h1, h2, h3, etc. When I first started playing with this, I tried it with body. Didn't work. After seeing your post, I gave html a try, but that doesn't work for me, either.

Wondering if the Voyage is that much different from the Paperwhite, or is it because I'm on 5.6.1?

Last edited by pssquirrel; 02-16-2015 at 10:55 PM.
pssquirrel is offline   Reply With Quote
Old 01-22-2015, 12:23 AM   #19
EbokJunkie
Addict
EbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blue
 
Posts: 229
Karma: 13495
Join Date: Feb 2009
Location: SoCal
Device: Kindle 3, Kindle PW, Pocketbook 301+, Pocketbook Touch, Sony 950, 350
@pssquirrel
Just try recipe from post #8. This is universal solution, should work on Voyage as well.
EbokJunkie is offline   Reply With Quote
Old 01-22-2015, 09:14 AM   #20
Section8
Addict
Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.
 
Section8's Avatar
 
Posts: 254
Karma: 2092424
Join Date: Oct 2011
Location: Arlington, TX
Device: Kindle PW4, Moon+ Reader on a cheap Android tablet
Quote:
Originally Posted by pssquirrel View Post
Curious. Negative left/right margins only work on my Voyage (5.6.1) when I set them for p, div, h1, h2, h3, etc. When I first started playing with this, I tried it with body. Didn't work. After seeing your post, I gave html a try, but that doesn't work for me, either.

Wondering if the Voyage is that much different from the Paperwhite, or is it because I'm on 5.6.1?
I had the same problem with a PW2 - also on 5.6.1. Setting the negative margin in the <body> class would work in the calibre viewer, or calibre editor preview window, but not in the kindle. I always assumed it was because margins at the <p> level overrode the body. But at least with azw3s converted from epubs (which is what most of mine are), using the html selector for negative margins does appear to work in the kindle.
Section8 is offline   Reply With Quote
Advert
Old 01-22-2015, 08:22 PM   #21
pssquirrel
ebooknut
pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.
 
pssquirrel's Avatar
 
Posts: 297
Karma: 688154
Join Date: Oct 2011
Device: Kindle Voyage & Oasis
@ Section8: Ah. I see what's happening now.

My source material is epub. I delete all margin-left:0 and margin-right:0 so that it uses the epub reader defaults. To get azw3, I convert epub > azw3 using Calibre and add negative margins in the Extra CSS section.

If I add negative margins to p, div, h1, h2, etc. everything works out fine.

If I use body or html, Calibre will sometimes (but not always) add margin-left:0 and margin-right:0 to the <p> elements, which overrides the negative <body> and <html> margins, rendering them useless.

I don't know how Calibre determines when to add margin-left:0 and margin-right:0 to <p>. If anyone has any clues, I'd be curious. However, I have no problem adding negative margins to <p> elements to get the desired results, and it's working fine.


Ignore what I wrote above. I was mistaken. I use the Extra CSS section to set negative margins in p, h1, h2, etc. This works fine. However, when I try it with body or html, the Extra CSS doesn't make it into the converted azw3. In this post kovidgoyal (Calibre creator) explains: "Extra css is not going to work for body/html margins. Those are controlled by the page layout section of the conversion dialog." That's why it doesn't work. Nothing to do with overrides or Voyage or 5.6.1, etc.

Good to know that, per Section8 and JSWolf below, you can use the html element if you convert from epub > azw3 first, then add it directly to the azw3 CSS using Edit Book.

@EbokJunkie: Thanks for your recipe, but I'm on a Mac!

Last edited by pssquirrel; 02-16-2015 at 11:00 PM. Reason: corrected info
pssquirrel is offline   Reply With Quote
Old 01-22-2015, 08:27 PM   #22
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,866
Karma: 128597114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by pssquirrel View Post
@Section8: Ah. I see what's happening now.

My source material is epub. I delete all margin-left:0 and margin-right:0 so that it uses the epub reader defaults. To get azw3, I convert epub > azw3 using Calibre and add negative margins in the Extra CSS section.

If I add negative margins to p, div, h1, h2, etc. everything works out fine.

If I use body or html, Calibre will sometimes (but not always) add margin-left:0 and margin-right:0 to the <p> elements, which overrides the negative <body> and <html> margins, rendering them useless.

I don't know how Calibre determines when to add margin-left:0 and margin-right:0 to <p>. If anyone has any clues, I'd be curious. However, I have no problem adding negative margins to <p> elements to get the desired results, and it's working fine.

@EbokJunkie: Thanks for your recipe, but I'm on a Mac!
What I have done is convert ePub > AZW3 and then in the Book editor, I replace all left and right margin of 0 to -30px and it works.
JSWolf is offline   Reply With Quote
Old 01-22-2015, 09:04 PM   #23
Section8
Addict
Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.Section8 ought to be getting tired of karma fortunes by now.
 
Section8's Avatar
 
Posts: 254
Karma: 2092424
Join Date: Oct 2011
Location: Arlington, TX
Device: Kindle PW4, Moon+ Reader on a cheap Android tablet
Quote:
Originally Posted by JSWolf View Post
What I have done is convert ePub > AZW3 and then in the Book editor, I replace all left and right margin of 0 to -30px and it works.
I was doing something similar, but based on JimmyR's suggestion above, I just add html { margin-left: -30px; margin-right: -30px; } to the CSS in the azw3, and the margins are reduced on the kindle. The various paragraph classes that calibre sets don't seem to override the html margin.
Section8 is offline   Reply With Quote
Old 01-22-2015, 11:28 PM   #24
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,866
Karma: 128597114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by Section8 View Post
I was doing something similar, but based on JimmyR's suggestion above, I just add html { margin-left: -30px; margin-right: -30px; } to the CSS in the azw3, and the margins are reduced on the kindle. The various paragraph classes that calibre sets don't seem to override the html margin.
I'll have to give that a try next time I convert an ePub > AZW3. Thanks for the suggestion.
JSWolf is offline   Reply With Quote
Old 01-23-2015, 12:17 AM   #25
pssquirrel
ebooknut
pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.pssquirrel ought to be getting tired of karma fortunes by now.
 
pssquirrel's Avatar
 
Posts: 297
Karma: 688154
Join Date: Oct 2011
Device: Kindle Voyage & Oasis
nevermind

Last edited by pssquirrel; 02-17-2015 at 12:38 PM.
pssquirrel is offline   Reply With Quote
Old 01-23-2015, 12:08 PM   #26
kentmatt
Member
kentmatt doesn't litterkentmatt doesn't litter
 
Posts: 22
Karma: 116
Join Date: Jul 2010
Device: none
Quote:
Originally Posted by Section8 View Post
I was doing something similar, but based on JimmyR's suggestion above, I just add html { margin-left: -30px; margin-right: -30px; } to the CSS in the azw3, and the margins are reduced on the kindle. The various paragraph classes that calibre sets don't seem to override the html margin.
Awesome. I did that, and it worked like a charm - a quick and easy fix to do when I convert. Thanks for that.
kentmatt is offline   Reply With Quote
Old 01-29-2015, 04:37 PM   #27
EbokJunkie
Addict
EbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blue
 
Posts: 229
Karma: 13495
Join Date: Feb 2009
Location: SoCal
Device: Kindle 3, Kindle PW, Pocketbook 301+, Pocketbook Touch, Sony 950, 350
Automated insertion of negative side margin tag html{...}

Please take a look at automated insertion of negative side margin tag html{...} in ePub->azw3 conversion flow. It is similar to those presented in post#8.
In that post Windows batch file provided only partial automation because it demanded user to determine the CSS class name used for paragraph rendering in intermediate ePub file.

Now that new idea of universal negative margin tag is suggested it looks as small change to batch file code from post #8 may provide fully automated operation.
Read preamble to post #8, download new Python app negmarg2.py, and try this batch file (uses Python 2.7):
Code:
:: Parameter #1: epub file name
:: Parameter #2: negative margin (enter POSITIVE decimal value in pt). Default is 9
::
:: How to call:
::1.  epub2azw3 book.epub
::   Provides default negative margins of 9 pt
::2.  epub2azw3 book.epub negative_margin
::   Provides  negative side margins equal to value of parameter "negative_margin" (value must be positive) 

ebook-convert %1 "%~n1_embed.epub" --output-profile kindle_pw^
   --embed-font-family "Charis SIL ModifiedLarger" --subset-embedded-fonts --minimum-line-height 125^
   --base-font-size 17 --font-size-mapping 13,13,17,17,18,22,24^
   --remove-paragraph-spacing --change-justification justify --margin-top -1 --margin-bottom -1

:: call python applet that inserts negative margin to css file.
:: margin is in positive number of points and comes from second parameter of this batch file
:: IF SECOND PARAMETER IS MISSING/BLANK DEFAULT VALUE 9 IS SET

if [%2]==[] (goto mdef) else goto mspec
:mspec 
:: Parameter #2 is in place
py -2.7 "%~dp0negmarg2.py" -e "%~n1_embed.epub" -m %2 
goto pass
:mdef
:: Parameter #2 is blank
py -2.7 "%~dp0negmarg2.py" -e "%~n1_embed.epub" -m 9
:pass

:: convert epub to mobi
kindlegen "%~n1_embed.epub" -locale en -o "%~n1.mobi"

:: extract azw3
py -2.7  "%~dp0\lib\kindleunpack.py" -s "%~n1.mobi" "%~n1"
:: copy mobi8-*.azw3 file into the current directory
copy ".\%~n1\*.azw?" ".\"
:: check if old  file *.azw3 exists and delete it
if exist "%~n1.azw3" del "%~n1.azw3"

:: rename mobi8-*.azw3 file
call renazw3 "mobi8-%~n1.azw3" 

:: remove intermediate file
del "%~n1_embed.epub"
del "%~n1.mobi"
:: remove scratch directory with unpacked files
rmdir "%~n1" /s /q
Please address post #8 for details.
Note that value of parameter --embed-font-family "Charis SIL ModifiedLarger" you should replace with the name of your favorite font (registered with Windows).
Also, you can remove this parameter if you don't want to embed your font.
Hope that someone will figure out how to convert this batch file to bash script and migrate it to Mac.

Last edited by EbokJunkie; 11-19-2018 at 02:03 PM.
EbokJunkie is offline   Reply With Quote
Old 06-24-2015, 11:49 PM   #28
thoreau
Enthusiast
thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.
 
Posts: 47
Karma: 28546
Join Date: Oct 2011
Device: KOA
Code:
html {
  margin-left: -27px;
  margin-right: -27px;
}
the above works great, but how do I change the top margin?

adding the below seems to have no effect on the output.

Code:
html {
  margin-left: -27px;
  margin-right: -27px;
  margin-top: -27px;
}
edit: also tried adding !important, but that gets me zilch too.

Last edited by thoreau; 06-25-2015 at 12:01 AM.
thoreau is offline   Reply With Quote
Old 07-22-2015, 11:28 PM   #29
thoreau
Enthusiast
thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.thoreau solves Fermat’s last theorem while doing the crossword.
 
Posts: 47
Karma: 28546
Join Date: Oct 2011
Device: KOA
Anybody know if it's possible to go negative on the top or bottom margins on kindle with css?
thoreau is offline   Reply With Quote
Old 07-23-2015, 06:07 PM   #30
EbokJunkie
Addict
EbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blueEbokJunkie can differentiate black from dark navy blue
 
Posts: 229
Karma: 13495
Join Date: Feb 2009
Location: SoCal
Device: Kindle 3, Kindle PW, Pocketbook 301+, Pocketbook Touch, Sony 950, 350
Quote:
Originally Posted by thoreau View Post
Anybody know if it's possible to go negative on the top or bottom margins on kindle with css?
Yes, at least negative top margin works (see attached).

Code:
html {
  margin: -17pt -11pt -17pt -11pt !important;
}
Attached Thumbnails
Click image for larger version

Name:	default_margins.png
Views:	565
Size:	34.5 KB
ID:	140506   Click image for larger version

Name:	negative_margins.png
Views:	589
Size:	37.6 KB
ID:	140507  
EbokJunkie 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
Best settings for 1:1 ePub to AZW3 conversion? gers1978 Conversion 8 06-03-2013 10:50 PM
azw3 to epub conversion stuck on 1% krysk Conversion 2 04-21-2013 11:53 AM
AZW3 to EPUB Conversion Probs grizedale Conversion 4 04-16-2013 06:47 PM
Conversion from epub to azw3 Joy736 Conversion 12 01-01-2013 11:00 AM
Using negative margins Agama Conversion 0 03-03-2012 07:29 AM


All times are GMT -4. The time now is 08:55 PM.


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