Hi Folks!
Brand new to the forum. I just though I'd share an automated tool/workflow
I created for convert Kindle ebooks to pdf without using Calibre or DDRM.
I created this tool after trying to convert a book I recently purchased.
https://www.amazon.com/Scales-Advanc...s%2C122&sr=8-2
I tried converting this book to PDF using Calibre and DDRM however I got out
weird nonsense. It appears azw uses some weird format, possibly vector graphics to describe sheet music. At least for this particular kindle book it does.
So my workaround was to just screen grab every page and convert to a PDF manually.
I created a python script to automate the screen grab.
Here are the tools you'll need if you wish to replicate. Currently this only works for windows, but I'm sure it could be replicated on other operating systems as well.
1. Python3.*
https://www.python.org/downloads/
2. pyautogui: For automating keyboard
pip install pyautogui
3. Kindle for windows: Any version should work. But 1.17 allows zooming
which was removed in later versions.
4. Greenshot: Better screen grab tool than Microsoft. Allows for automation
https://getgreenshot.org/downloads/
5. ImageMagick: To convert png files to PDF.
https://imagemagick.org/script/download.php#windows
Once you have all above installed we can begin.
First create a folder to store your converted ebook.
Then open Greenshot->Preferences
Click General tab
Ensure the hotkey for Capture last region is set to "Shift + Printscrn"
Then click on Output tab
Set storage location to the folder you created.
Set Filename pattern to ${NUM}
and image format to png.
Now open your Kindle for windows and open to the first page of your desired
ebook.
Then open a power shell window. Right click run as administrator.
run The provided python script.
python run.py
First it will prompt you to input the total number of pages of the book.
Input that. Then the script will prompt you to go back to your kindle app and manually screen capture the first page.
Go and click Greenshot->Capture region.
Click and drag the region of your page. This will be the same region captured for all other pages so ensure you like the capture region. ALSO make sure not to resize Kindle or move window or it will break screen capture.
Then return back to the power shell. DO NOT CLICK ANY OTHER WINDOWS.
I use alt tab to return to the previous window. You can double check by hitting
alt+tab and ensuring it returns you to Kindle app and not some other window you clicked on by mistake.
Then hit enter and wait.
The script will cycle through pages screen grabbing them and saving to your desired folder. DONT click anything until done.
Finally you should have a folder full of PNG files in numerical order.
Double check all pages are there. They should be unless your computer is slow and can't keep up with the input commands.
Finally you can use imagemagick to convert to pdf.
from the folder run
imagemagick convert *.pdf -quality 100 -units PixelsPerInch -density 72x72 output.pdf
And if all goes well you should now have a PDF.
Troubleshooting.
The captures will only have the resolution that they are currently being displayed on your screen. To get good quality make sure you have your display settings as high as possible and make the kindle window as large as possible.
If you have a small monitor. Consider rotating vertically. Also you can make your pc run in a higher resolution than your monitor supports.
See
https://www.geekcosmos.com/how-to-ta...nitor-windows/
I currently set the delay between automatic key actions as half a second so
that Kindle and Greenshot can keep up.
Feel free to go into code and make these smaller if you're impatient
look for
key_press_delay_short=0.01
key_press_delay_long=0.5
Anyway. I hope this is helpful as a last resort for converting kindle books to PDF. I needed to print these for my lesson next week and there was no online retailer that could get me a print copy in time.
RESPECT PUBLISHERS! USE THIS TOOL FOR YOURSELF NOT FOR PIRACY