Since the launch of Scribe,
Send to Kindle service has converted PDFs to Print Replica for Scribe. And sometime in the last week or so, the Kindle apps also get Print Replica.
For the most part this is a totally good thing: Print Replica backs up annotations, and syncs between devices. But what if you want to have the service deliver PDF instead?
For example, navigation in landscape orientation for Print Replica on Scribe does not work as well as for PDF. For PDF, tap advances the next section of page on screen, and then advances to the next page. They forgot to implement this for Print Replica, so you have to resort to precise drag gestures.
Well, it turns out that conversion fails if there are more than 1000 PDF bookmarks, and it will deliver PDF instead for the lifetime of that personal document (or until the limit changes).
This script will take a PDF and output one with 1001 bookmarks added to it (all of these will navigate to page 1).
Code:
from os import path
import sys
import fitz
'''
Creates 1000 bookmarks to prevent PDF from being converted to Print Replica
by Send To Kindle service.py
'''
try:
pdf = sys.argv[1]
if not path.isfile(pdf):
raise FileNotFoundError
except (IndexError, FileNotFoundError):
print('Please specify the path to an existing PDF file, e.g.:\n > python bookmark_hack.py [pdf_path]')
exit(1)
doc = fitz.Document(pdf)
toc = doc.get_toc()
dummy_toc = [[1, 'Dummy TOC', 1]]
for b_num in range(1, 1000):
dummy_toc.append([2, f'Dummy TOC entry {b_num}', 1])
toc += dummy_toc
doc.set_toc(toc)
doc.save(f'{path.splitext(pdf)[0]}_hacked.pdf')
This has a dependency on PyMuPDF, so some setup required. Python 3 recommended. E.g.:
Code:
python3 -m venv venv
source venv/bin/activate
python3 -m pip install -U pymupdf