Friday, September 23, 2011

the calibre viewer

Today we explore the many features of calibres ebook viewer. calibre's ebook viewer allows you to view ebooks in all of the 22 input formats that calibre supports conversion from. These include CBZ, CBR, CBC, CHM, EPUB, FB2, HTML, HTMLZ, LIT, LRF, MOBI, ODT, PDF, PRC, PDB, PML, RB, RTF, SNB, TCR, TXT, TXTZ, and no, I did not make that up ;-) They are all existing ebook formats.


However by default only files in EPUB, FB2, HTML, LIT, LRF, MOBI, PDB, PRC nad RB formats are opened in the calibre internal viewer. This is because for the remaining formats, usually a better result is obtained by viewing in an external viewer; like acroread or okular for PDF. For these other formats calibre will automatically open the files in an external viewer unless you ask it to open in the internal viewer. To choose which formats you would like to view using calibre's internal viewer go to Preferences -> Behavior -> and select the formats you want in the right column.


The buttons

The top left corner of the viewer gives you a location as a decimal number. This does not change when you change the viewer window size or the font size. So you can always use that number to refer back to a particular part of the book. The buttons in the ebook viewer have been labelled in the figure below. We will go through the functionality of each.




Back and forward buttons: These buttons will only be functional if your ebook has links in it that take you to other parts of the ebook or if you click on an entry in the table of contents (discussed next). Once you click on a link you can use the back button to take to the place you were before you clicked the link. These buttons are similar to back and forward buttons on a browser.

Table of Contents (TOC): Clicking this button opens up a TOC as shown in the figure below. You can navigate through the chapters of the book by clicking on the entries of the TOC. The figure shows that when the entry "ABSENT TREATMENT" is clicked in the TOC the viewer takes you to that chapter. Clicking on the TOC button again will make the TOC disappear.



Previous and Next page: These buttons should be used to navigate pages. Not the back and forward buttons which become activated only when a link is clicked or the TOC is used.

Bookmark: When this button is clicked a window opens that allows you to choose a helpful name for the bookmark so you can refer to it easily later.

Reference mode:
When this button is clicked and the mouse is hovered over any text, a unique number referring to the paragraph to which the text belongs is displayed. This number is independent of viewer window size or font size and can be used to refer to the paragraph.

Preferences: Clicking on this button opens a new window with three tabs. The first tab is "General" and here you can choose the default font you would like in each font family as well as the font family. You can also choose some window and mouse settings to suit your convenience.
The next tab is "Keyboard Shortcuts". The calibre has a default set of shortcuts for taking you to different sections of the ebook or for scrolling. For example by default the viewer uses the "J" or "Down arrow" key to scroll down the document, however if you dont like this choice you can double click on it. Initially "Default" is selected, but you can select "Custom" and it will let you choose upto 2 keyboard shortcuts.

The third tab is "User Style Sheet". Here you can customize the background colour, indentation, relative font sizes of section titles or chapter names etc. To do this you have to create a custom style sheet (CSS).  Here is an example:

body {color:black !important;
background-color:rgb(228,200,200) !important;
text-align:justify !important;
text-indent:3em !important;}
h1, h2, h3, h4, h5, h6
{color:red !important;
text-align:center !important;
font-style:italic !important;
font-weight:bold !important;}

The first line sets the text color to black. On the second line is a command for the background color in RGB. The particular values chosen here generate the pink background in the following figure. The third line ensures the text ends at the same position on the right end of the viewer (compare figure below with figure above). The fourth line specifies the indentation at the beginning of each paragraph. The lower set of commands sets the text style for headings (hi, h2 ... , h6) to have color red, aligned center, in italics and bold. So even if you don't know how to create a CSS all on your own just copy an example CSS and tweak the values to get the colors alignment and indentation you want. Notice the "!important" in every line of the CSS. That is required to override the style already specified in the epub book. To see the effect of each of these elements of the style sheet compare the figure below which uses the above CSS with the one above (no CSS). The TOC was removed in the figure below by just clicking on the TOC button.




CSS allows you to make many other powerful stylistic changes. For help with writing CSS or for some more examples visit the CSS thread on calibre's library management forum on mobileread.




Metadata: Clicking on this button displays the metadata of the book on the viewer screen. See figure below


Hope you found this useful. Please feel free to comment. See you in about a week.

13 comments:

  1. If you're selecting a font that is not pre-loaded on a person's ebook reader, how do you attach the ttf file for your target font?

    will this over-ride a user's selection of a font from an ereader's pre-loaded font library?

    ReplyDelete
  2. @Becca: Sorry, but calibre does not support font embedding.

    And as for the font selection mentioned in this blog post, it is the font you see on the calibre viewer, not on your ebook reader.

    Does that answer your question?

    ReplyDelete
  3. Hey, Calibre...
    Thank you thank you thank you all you anonymous people for the treasures you have given us.

    ReplyDelete
  4. Guys this blog is awesome, as is your product. Thank you for being you - developers of great tool for every book lover.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Nice post, thanks for taking the time to do this.

    Unless you add

    text-indent:0em !important;

    Under the h1, h2, h3, h4, h5, h6 area your headers will be 3em off center and look bad.

    ReplyDelete
  7. Very grateful for the work you put into this great program and as I pass it on to my friends who are acquiring Kindles I do request they make a donation to keep you guys alive and happy. Can't do more than that.

    ReplyDelete
  8. @Lloyd and Anne Brady: thanks a lot for spreading the word :)

    ReplyDelete
  9. Hello,
    I have a little problem with the Extra CSS.
    When I convert from e.g. RTF to MOBI, extra CSS does not work properly for me.
    The code which I typed in:

    h1 {font-size: 120%; font-style: italic;}
    h2 {font-size: 150%; font-weight: bold;}
    h3 {font-size: 135%;}

    This code successfully modifies the font size, but it does not do anything with the style or weight.

    Is there any solution for this?

    Thank you

    Alex Silver

    ReplyDelete
  10. Hi. Does the "go to" function allow you to enter a specific page and skip directly to it? Thanks

    ReplyDelete
  11. Do Caliber has Auto scroll feature ?

    ReplyDelete