![]() |
#1 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,267
Karma: 25241353
Join Date: Apr 2009
Location: USA
Device: iPhone 14PM, Kindle Scribe, iPad mini 6, PocketBook Era
|
Prevent Send To Kindle from converting to Print Replica
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') Code:
python3 -m venv venv source venv/bin/activate python3 -m pip install -U pymupdf Last edited by tomsem; 09-27-2023 at 05:58 PM. |
![]() |
![]() |
![]() |
#2 |
the rook, bossing Never.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,596
Karma: 79410001
Join Date: Jun 2017
Location: Ireland
Device: Both Kinds: epub based makes and Kindle
|
Use USB. Simple.
|
![]() |
![]() |
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,267
Karma: 25241353
Join Date: Apr 2009
Location: USA
Device: iPhone 14PM, Kindle Scribe, iPad mini 6, PocketBook Era
|
|
![]() |
![]() |
![]() |
#4 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,062
Karma: 94986278
Join Date: Apr 2011
Device: pb360
|
Quote:
I do have some questions. Over time you have frequently mentioned PDF bookmarks. Is that some internal Adobe term? Are they somehow different from TOC entries? (you invoke functions get_toc and set_toc) (I know that epub, amazon, and pdf have provisions for a "table of contents" that can be used by a reading device that is not displayed while paging through a document. Some documents have that or a TOC that is an inline part of the document or both) If the above paragraph is not clear, please ask for clarification, or just try to sus it out, rather than attacking some nomenclatural deficiency. (Supplying corrections is of course welcome.) |
|
![]() |
![]() |
![]() |
#5 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,267
Karma: 25241353
Join Date: Apr 2009
Location: USA
Device: iPhone 14PM, Kindle Scribe, iPad mini 6, PocketBook Era
|
Quote:
PyMuPDF's '_toc()' functions only work with PDF, but manipulate what Adobe calls Bookmarks. PyMuPDF's '_bookmark()' functions are only for reflowable documents (ePub, mobi, FB2, CBZ, SVG, XPS). I haven't used it for anything but PDF so far. It looks like it has some interesting capabilities for the other document types, and has an OCR API to integrate with Tesseract. https://pymupdf.readthedocs.io/en/latest/about.html I encounter many PDFs which lack any Bookmarks whatsoever, and/or have an inline Table of Contents that doesn't have page links to the respective chapters (to say nothing of linking footnotes or index entries). I want to send these to my Scribe (and as of recently, the Kindle apps) and at least want to have a functional ToC in the converted Print Replica document (the default ToC is useless). So next on my task list is to scan a PDF for chapter/section headings, and create Bookmarks that will get converted to the Print Replica ToC. Last edited by tomsem; 09-28-2023 at 09:03 PM. |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help With Converting KPF Print Replica Files to ePub on Calibre | AdamH9999 | Conversion | 5 | 06-14-2021 01:23 PM |
Print replica books | Waylander | Amazon Kindle | 2 | 07-02-2018 10:22 AM |
Converting AZW4 print replica into PDF format. | Akrite | Conversion | 12 | 07-09-2015 01:30 PM |
Is no 'print-replica' a problem? | calvin-c | Conversion | 2 | 01-21-2013 05:58 PM |
Converting Kindle ebook to print? | tinabryan410 | Reading and Management | 3 | 10-23-2012 04:07 PM |