DON'S FREEWARE CORNER - APR 2016
USING K2PDFOPT AND CALIBRE TO CONVERT A PDF TO EPUB FOR MOBILE DEVICES

©2016 Donald R. Snow
This page was last updated 2016-06-13.
 
These Freeware Corner notes are published in TAGGology, our Utah Valley Technology and Genealogy Group (UVTAGG) monthly newsletter.  They are also posted on my Freeware Corner Notes page on  http://uvtagg.org/classes/dons/dons-classes.html  where you can just click on the links and there may be corrections or updates after the printed version.

PDF'S AND EPUB'S
PDF (Portable Document Format) is the format that Adobe developed and which has been accepted by many organizations as a standard for documents, since it appears exactly the same on any computer and in any operating system.  There are several varieties of PDF, but all have the image layer which is just a picture of the page.  This may include text or photos or anything else.  To be searchable, besides the image layer, there has to be a text layer which shows that the various symbols on the image represent words.  This text layer is formed by OCR'ing (Optical Character Recognition) the image layer and is superimposed over the image layer so it shows where the words are on the page.  These can be in English or French or other language.  Because the image layer is only a picture of text and not text itself, the font or font size can't be changed on a PDF and the only way to make it larger is by enlarging the entire page.  This may make it so you have to scroll to see it all on small screen.  EPUB and other mobile device formats are different, since they have the text itself in them, so it is possible to change the font and font size without changing the page size.  Because of this people have developed ways to convert PDF's into EPUB's to read on small-screen mobile devices.  The conversion may require that one PDF page goes into 3 or 4 EPUB pages.  One  method of conversions is to first change the PDF into html (computer jargon for hypertext markup language) and then change that to EPUB.   This requires OCR'ing the document first, noting the paragraphs, lines, tables, etc., converting that to html, and then converting the html to EPUB.  Because of the complexity of PDF's, CALIBRE doesn't do a very good job of converting directly from PDF to EPUB and the CALIBRE Manual even states that PDF is the absolute worst format to start with for such conversion.  A comment I came across on a forum about how to do this conversion suggested that you can improve the final EPUB result from CALIBRE by first converting the PDF to a different format of PDF by using the freeware program K2PDFOPT before running that in CALIBRE to convert to EPUB.  That's what this Freeware Corner article is about.

K2PDFOPT -- available from   http://www.willus.com/k2pdfopt/download/
This free program helps make PDF and DJVU files more readable on small devices, e.g. smartphones and tablets, but they are still PDF or DJVU files.  DJVU is another document format type, but not used as widely as PDF.  With this program you can crop the pages, set the margins to be narrow or even 0, and set many other preferences to make it more readable, but it is still a PDF.  The statement was made that this new PDF converts in CALIBRE to a better EPUB than the original PDF and my quick experiments seem to verify that.  

USING K2PDFOPT
There is an 8-minute YouTube tutorial about K2PDFOPT at  https://www.youtube.com/watch?v=oCkJ3hLuT3E  and there are Helps on the main webpage.  To use K2PDFOPT download the version you need from the webpage, e.g. my computer needed the Windows 7x64-bit version.  It downloads as the executable file, i.e. the .exe file, and doesn't need to be installed on your computer.  After downloading I right-clicked on it to make an icon on my desktop so I can run it without looking for it every time.  The program opens with a window where you add the PDF files to convert and there are lists of settings you can change.  You can add one or more PDF's at a time.  Here are some of the settings and what I used.

Where to store the final file?
How much to crop each page?  (I said, don't crop at all.)
What margins to use in the final file?  (I left these set to 0-inch margins all around each page.)
Maximum number of columns per page?  (I left this at 1, even though the book PDF I worked on had two columns per page.)
What final device format do you want, e.g. several Kindle versions, several Nook versions, Kobo, or Nexus?   (The YouTube tutorial says that all it really needs to know about your mobile device are the dimensions of its viewing screen.)

The settings can be saved with a name so you can click and bring those all in at once next time. There is a Preview panel where you can select a page from the old PDF and see what its conversion will look like, but I haven't used that.  With everything set click Convert All Files and it starts through the old PDF's, first examining their properties and then converting them.  The example I used was a 197-page book I had downloaded in PDF format from HeritageQuest Online a couple of years ago.  The conversion seemed to take about 1 second per PDF page.  It showed me how many new PDF pages each old PDF page had gone into.  In my example I had set it to have only one column and this caused each original PDF page to go in one new PDF page, even though most pages had two columns.  The entire 197-page PDF book took about 3-4 minutes to convert.  It saved the new PDF file where I had told it to and added "k2pdfopt" at the end of the name, so it didn't overwrite my original PDF file in the same folder.  There are additional things that K2PDFOPT can do and further information about it in the tutorials.

USING CALIBRE TO CONVERT TO EPUB FORMAT
CALIBRE was discussed in my Freeware Corner column last month (Mar 2016) and there is a 10-minute CALIBRE tutorial at  https://calibre-ebook.com/demo .  A short summary of CALIBRE is that it is an open source program, and hence free, available from  https://calibre-ebook.com/ , that is an ebook library cataloger, manager, reader, converter, viewer, and editor, and works with many different ebook formats.  It will also convert ebook files between many different formats and also has features to go out on the Internet to find other ebooks you want.  It is cross-platform so there are versions for Windows, OS, and Linux.  To transfer ebooks in CALIBRE onto your mobile device you connect the mobile device to your computer and CALIBRE detects the connection in a few seconds.  Then highlight the ebook you want to transfer, click Send To Device, and it is transferred.  If it isn't already in the format needed by that device, CALIBRE will convert it to the needed format as it is transfered and it will then be on your mobile device ready to be read.

To use CALIBRE to convert the new K2PDFOPT PDF click the Add button (top left) on CALIBRE and tell it where to find the new PDF.  It brings it in, recognizing and keeping track of its properties.  After a few seconds you see it listed in your CALIBRE Library list.  If you click on it there or on the word PDF in its property list on the right-hand side, it shows it in the PDF reader you have designated as the default on your computer.  To convert it to EPUB format highlight it and click on the Convert Books button at the top and set the settings the way you want.  It will start converting the new PDF and when finished in a few seconds you will see EPUB added to the format types in the properties for that title.  Clicking on EPUB there will now open it in the CALIBRE EPUB reader.  EPUB readers allow changing the font and its size, so you can experiment to see what makes it more readable.  It also has a search feature to find any word or character in the entire ebook.  Because of the smaller size of the window on a mobile device window a single page of the original PDF may be divided into several EPUB pages.  I have noticed that the general formatting doesn't look nearly as good as in the original PDF's, so it may still be hard to read.  But now the text font is scalable, i.e. changeable.

CONCLUSIONS
This program may help in converting PDF's to make them readable on your mobile devices, either by just using the K2PDFOPT PDF formed from the original or by taking the next step and converting that to EPUB format.
=================================