How to view and convert KFX files in Calibre - Tutorial
Updated: May 13, 2019
Calibre Dedrm Kindle Mac
Run Calibre again. In the Preferences Plugin and click Load plugin from file, and add the new DeDRM plugin to Calibre. Close Calibre and restart it. Workaround 3: Instead of Calibre, Using Epubor Ultimate. For Mac, Kobo, and Nook users. Calibre DeDRM plugin will not so helpful, and we recommend using Epubor ultimate. On a Mac, Calibre defaults to creating its 'Calibre Library' file under the username directory. If everything has gone correctly, you should have a bunch of sub-folders, organized by author’s.
This is a rather interesting topic. Over the years, Amazon have changed the Kindle file format several times. Their digital books came in a variety of formats, including AZW, then AZW3 and finally KFX. The last one is a complex archive that combines numerous features, including typesetting engine, fonts, multi-page thumbnails, and also DRM. I noticed this starting with Decay, one of my books published in 2017.
Reading some more, I realized KFX seemed to include DRM even for books that are not meant to use DRM, and I found this quite weird, because as an author, I have specifically chosen not to publish my own works with any sort of lock-in encryption. So this got me thinking. Is there a way to actually convert KFX into the old format, or other e-book formats, and use them in Calibre and other readers, the way the older formats allowed? Follow me.
Basic tools, requirements & disclaimer
What you want to do is simple: convert KFX files to other formats - for archiving, backup and publication testing purposes, so you can use them on different e-reader devices. If you try to open a KFX file in a typical e-book reader, you probably won't succeed. For instance, Calibre cannot read this file format natively. The solution is then to convert the file, our task for today.
I spent a good few hours reading about this topic, compiling information, trying to find out all the necessary bits and pieces to get the job done. In the end, I did successfully manage, but it wasn't trivial, and there are still many ifs and buts to the whole thing. So let's start with the tools:
- I tested this on a Linux system (Ubuntu-based).
- Calibre software (apt-get install calibre or dnf install calibre, for instance).
- DeDRM Calibre plugin.
- KFX Input Calibre plugin.
- Your Kindle device serial number.
- KFX book (which includes ALL the files and associated folders for the specific book on your Kindle).
You will need to feel comfortable installing Calibre plugins and working with archives. If you can't do these things easily, you will probably struggle getting the job done here.
Disclaimer
The purpose of this guide is not to teach you how to hax0r your way around. The purpose is to allow you to decrypt your own books and use them on your own devices. In fact, the DeDRM plugin listed above does not work with rented or lent books - it only works for the books you have purchased yourself.
There are also numerous technical limitations on how well the tools listed above work, including the version of Kindle software and such. In my test, I did not encounter any such problems. But please take this into consideration as you read on.
Before you start ... download non-KFX books
When you purchase a Kindle book, and then go to your Kindle library, you can choose different delivery methods. You can send books directly to a Kindle device or reader, and you can also transfer them via USB. This will effectively download the book to your local computer, which you can then copy to the relevant device. For the time being, books downloaded via USB come in the non-encrypted AZW format, but this may change. So this is your first and best options, before doing any fancy conversions! If the book is in your Kindle library, then you are all set.
Calibre plugins setup
After you install and start Calibre, you will need to install the two plugins (Calibre > Preferences > Plugins). KFX Input is available in the list of plugins, although you can also download it manually (see the linked forum thread at the beginning of the page). DeDRM is available from GitHub. Both plugins come as ZIP files. The DeDRM plugin ZIP contains more than just the plugin itself - but it also has what we need, the Calibre plugin.
To install KFX Input, click on Get new plugins, select, install, restart Calibre.
To install DeDRM, download the zip file from GitHub, extract it. Next, in Calibre, click on 'Load plugin from file' in the plugins window, navigate to the Calibre sub-folder in the extracted archive and then select the plugin zip. If you have chosen the 'wrong' zip (such as the external zip archive), you will see the It does not contain a top level __init__.py file error. Once you've installed this plugin too, restart Calibre.
DeDRM setup
Your next step is to configure the DeDRM plugin. Open the plugins list, search for DeDRM in the list. Double-click on the plugin, and it will open the customization window. You must configure the plugin, otherwise it will not work. And this is probably the most complex step. Because not everyone has a Kindle device, and this is where it gets complex. There are various technical limitations on different types of devices, like Kindle for Android or Kindle for Mac.
I selected eInk Kindle books - please note I own a Kindle device, and I connected it via USB to my Linux machine, and then copied my Decay book over ( all Decay* titled files, KFX plus folder). When you select this option in the DeDRM customization screen, you need to add a serial number for your Kindle device. It's a 16-digit string composed of numbers and digits (no spaces).
Add KFX book to Calibre
The next step is to add your KFX book to Calibre. If you have already added it to Calibre, remove it and then add it fresh. DeDRM runs on first import only. If you've configured everything correctly, DeDRM will run now. This can take a few seconds.
While this was happening, in the background, DeDRM configured WINE for Linux, probably so it could install various Windows-based tools it needs to create decryption keys. There's no need for you to do anything manually, but you should be aware of this, especially since it creates a new WINE configuration directly in your home directory, and not as a hidden object (no dot prefix), so this may pollute your home - you will suddenly see drive_c and various WINE reg files there.
And then, it was done. The book was imported. I noticed the cover image was black & white rather than color, but that's easily solvable. I opened the book in the Calibre ebook reader, to verify that I indeed the DRM component was removed.
Convert to other formats
The next step is to convert the book using KFX Input. This is an optional step, but if you want to have your book in AZW3 format, or maybe EPUB or alike, then you can use this plugin. This can be quite useful if you have multiple ebook devices, or want to keep a backup of your own files - although they should all be available in your Kindle library, but still.
I then opened the file in the Calibre ebook reader, to make sure everything is dandy:
And that's it. We're done. Happy times.
Various errors
In case things didn't work as they should, then you will see various errors, apart from the DeDRM plugin ZIP error we've already discussed. First, if you try to open a KFX file in Calibre without the use of the DeDRM plugin, you won't be able to do so. Moreover, if you try to use KFX Input before DeDRM has run, you will not be able to convert the file, even if you did select the option to ignore errors during the conversion process.
Conclusion
Hopefully, this guide was useful. I have never really needed the ability to open any KFX file in Calibre before, because I'm happy using and reading them on my Kindle. But when it comes to my own books, the books I've written myself and then published WITHOUT DRM, then I expect to actually be able to work with these files, including any pre- and post-publication processing required - after all, this allows me to test how the digital books render on different devices, and make sure that my readers get the best experience.
This isn't a trivial tutorial - it uses Linux (which may already be too much), requires two Calibre plugins, and you need some tweaking to get things working. But in the end, we did succeed. For people who can't be bothered, my advice is to grab the files from your Kindle library using the USB option, this way you won't need to worry about the KFX conversion. Alternatively, this article outlines the steps you need to get the job done. See you out there, and enjoy your books!
Cheers.
I started this thread with the ideea that many don't know where to go for information to dedrm books (and recently I had to install all, I mean all the programs on my personal PC )The most easy and practical way to remove DRM from a book it's with Calibre, and below are the instructions.
Have fun
About calibre
Calibre is a free, open source, ebook management and conversion utility created and maintained by Kovid Goyal. It is available for Windows, Mac OS X and Linux.
Calibre cannot, on its own, remove DRM from ebooks. However, it is possible to added third-party software (‘plugins’) to enhance calibre.
To be able to use the DeDRM plugin for calibre, it is necessary to install calibre first. The latest version can be downloaded from calibre - Download calibre
Installing the DeDRM plugin for calibre
The latest tools_v6.5.1.zip can be downloaded from https://github.com/apprenticeharper/...ses/tag/v6.5.1
1. Download the latest tools package, and unzip it.
2. Run calibre. From the Preferences menu select “Change calibre behavior”.
(Do not click “Get plugins to enhance calibre”, that option is reserved for ‘official’ calibre plugins.)
3. Click on Plugins (under “Advanced”) — it looks like a jigsaw puzzle piece.
4. Click on the large “Load plugin from file” button
5. Navigate to the tools folder unzipped in step 2
6. Open the “DeDRM_calibre_plugin” folder
7. Select the DeDRM_plugin.zip file in that folder
8.
Calibre Dedrm Macos
Click on the “Add” (sometimes “Open”) button.9. Click on the “Yes” button in the “Are you sure?” warning dialog that appears. A “Success” dialog will appear, saying that the plug-in has been installed. Click on “OK”.
Using the DeDRM calibre plugin
The DeDRM calibre plugin removes DRM from ebooks as they are imported into calibre. So to use the plugin, just import your DRMed ebooks into calibre, and the DRM will be removed. If you have already imported your ebooks into calibre, you will need to remove the DRMed ebooks and import them again.
You can check that the DRM has been removed from an imported ebook by trying to view it using calibre’s built-in viewer. Note that for .azw3 Kindel ebooks you might need to check a checkbox in calibre’s preferences to say that .azw3 ebooks should be viewed using calibre’s internal viewer.
If things go wrong
The calibre developers are not involved in the development of the DRM removal plugin, and are not able to help with any DRM removal questions. If you have any difficulties following the instructions in this post, the calibre developers will not be able to help.
Credits
Most of the work on converting the DRM removal scripts to a calibre plugin has been done by DiapDealer and Apprentice Alf.
Now we are prepared to strip the book by her DRM protection so will follow next :
There are several ways to go about getting your DRM-loaded Kindle books. You can:
- Mount your Kindle as a USB device and pull them off.
- Download them using the Kindle for PC app.
Let’s look at each technique in order to highlight the benefits/shortcomings and what you need to do.
Copying the Books from Your Kindle: If you’re going to rip the book directly from your Kindle device (or use the download and transfer technique), you need to manually enter the serial number of your Kindle into the DeDRM removal plugin. Do so by navigating back to Preferences -> Advanced -> Plugins -> File type plugins and double clicking on the entry for DeDRM. You’ll see a box like so:
Click on the first entry “eInk Kindle ebooks” and, in the resulting dialog box, click the + sign and enter the serial number off the back of your Kindle.
Double check the serial number; any discrepancy between the serial number in the book file and the plugin will lead to decryption failure.
Downloading Your Books via the Kindle for PC App: If instead you have sent your Kindle books to Kindle for PC, and we strongly recommend this method because it’s so easy, you can find the locally stored books in the following directory:
C:Users[Your Windows Username]DocumentsMy Kindle Content |
Each Kindle book you import to Kindle for PC will have two companion files (.MBP and .PHL files); you can ignore the extraneous file types. Books will also have odd names, like “B001QTXLQ4_EBOK”. Don’t worry the proper name and author data are stored in the files. This technique is nice because you can snatch all your books in one swoop and dump them into Calibre. Simply select all the actual book files (all the .AZW, .TPZ, and .MOBI files) and dump them right into Calibre to import them.
Now, Calibre will import any ebook file (DRM-laden or DRM-free) without a hiccup. The real test of whether or not the import-and-strip process has worked properly is to try and convert the book into a new format. Right click on the entry for the new book and select Convert Books -> Convert Individually. This will pull up the conversion menu. Convert it to any other format, it doesn’t matter which.
If the book’s DRM hasn’t been properly removed, you’ll get an error like this:
Now, this error does not necessarily mean that the DeDRM plugin isn’t working properly. If you’re loading books off your physical Kindle and you entered the serial number wrong in the DeDRM configuration, the process would fail like this. If you tried to add Kindle books that you’re not the actual owner of, it will also fail.
Load the books from the proper source, however, and the process starts successfully.