¡Progress on PDFs! PDF reader devlog 1
[ID: The first image shows a page from a PDF file with a short story by writer Julio Cortázar.
The entire PDF has a white overlay over it, dimming most of the text. The area approximately matching one of the sentences is cut out of the overlay, revealing the original text underneath. The revealed sentence has a faint yellow highlight overlay. It roughly mimics the behavior of the Sentence-Stepper reader addon.
The second image shows the same page from the same PDF file converted to HTML format.
The page is displayed in dark mode with white text against a dark gray background, and the Sentence-Stepper reader addon is being used on it, like it would be used on any normal website.
Both files are seen inside a custom rudimentary PDF viewer which allows for the options to load a new PDF file, move back and forth through pages and jump to a specific page. END ID.]
---
Here's how the pdf situation is going at the moment, I'm making my own built-in viewer and I have two options I want to include:
1️⃣ Load a PDF as-is and use overlays to mimic the highlight effect:
Since I can't actually edit the PDF's text, I'm overlaying a white semi-transparent sheet and then cutting holes into it so you can see the sentence underneath (with dark mode I overlay a black sheet instead).
The downside of this is that I can't use my styles from the regular addon's toolbar, I'm forced to make new ones that overlay on top of the text unless I can figure out how to manipulate the text itself. I'm still working out how to properly separate the sentences and correctly position the overlay effects.
But the obvious positive is that the PDF is visually unaltered save for the overlays, which I can imagine is needed for complex formats like scientific articles or magazines.
2️⃣ Parse the PDF's content as HTML
This has the advantage of allowing for true dark mode, font size change, and the full use of the Sentence-Stepper addon as you would use it on any other website.
However it has the downside that it would mostly work only with PDFs that are just simple plain text. I'm trying to figure out how to preserve images and data tables but most of the formatting would be lost in the conversion.
I suppose something is better than nothing? I want to include both options. However I'm struggling with the issue that bundling in the PDF viewer makes the addon go from a just a few mere kilobytes to 35Mbs in size, so maybe I will ship the PDF viewer separately as a different addon ("PDF-stepper"?) to preserve Sentence-Stepper's current light weight as it is.
Update on that last part: I got it down to 13MB so I'm bundling it.








