Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-22-2022, 09:50 PM   #1
mhorowitzgelb
Junior Member
mhorowitzgelb began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jan 2022
Device: Windows
Automated Kindle -> PDF Without Need For Decryption

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
mhorowitzgelb is offline   Reply With Quote
Old 01-22-2022, 09:54 PM   #2
mhorowitzgelb
Junior Member
mhorowitzgelb began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jan 2022
Device: Windows
woops here is the python script
Attached Files
File Type: py run.py (891 Bytes, 320 views)
mhorowitzgelb is offline   Reply With Quote
Advert
Old 01-22-2022, 09:59 PM   #3
mhorowitzgelb
Junior Member
mhorowitzgelb began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jan 2022
Device: Windows
Also btw this tool really should work for any Digital content reader.
Any reader where the "Down" button goes to the next page will work.

If not you can modify the code to whatever key is necessary.

See pyautogui
https://pyautogui.readthedocs.io/en/latest/

keyboard key names
https://pyautogui.readthedocs.io/en/...#keyboard-keys
mhorowitzgelb is offline   Reply With Quote
Old 01-22-2022, 10:11 PM   #4
mhorowitzgelb
Junior Member
mhorowitzgelb began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jan 2022
Device: Windows
Sorry there was typo in imagemagick command.
Why won't it let me edit posts?

Anyway should be
imagemagick convert *.png -quality 100 -units PixelsPerInch -density 72x72 output.pdf
mhorowitzgelb is offline   Reply With Quote
Old 06-05-2024, 10:18 AM   #5
stearno
Junior Member
stearno began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Jul 2017
Device: tablet
Two updates

First, magix has changed its commands. The command is now:
magick *.png -quality 100 -units PixelsPerInch -density 72x72 output.pdf

Second, I had to go into Greenshot / Preferences / Destination. Uncheck Dynamically, and check Save Directly.
stearno is offline   Reply With Quote
Advert
Reply

Tags
azw, conversion, ddrm, kindle, pdf


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Any automated Kindle Page turners? eatyourpaprikash Amazon Kindle 27 07-19-2021 04:51 AM
automated conversion excepting pdf jomaweb Conversion 1 05-15-2018 04:44 PM
ePub & PDF decryption on Mac OSX edembowski ePub 195 02-25-2011 05:13 AM
Hacks Trying to setup an automated system to backup kindle... jer989 Amazon Kindle 10 10-02-2010 04:14 AM
Decryption Failed! dmacmart Kobo Reader 4 08-28-2010 04:01 PM


All times are GMT -4. The time now is 03:57 PM.


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