Repository navigation
Conversation
When a PDF has files embedded at the document level, the sidebar gets a Files tab that lists them and saves each one exactly as it was attached. PDFs without attachments show no extra tab. Names come from the PDF, so they are reduced to a plain file name before being shown or saved. Files attached to a page as annotations and reading attached PDFs in their own tabs are left out, as agreed in Forward-Future#53.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A PDF can carry files embedded in the document itself (a spreadsheet, a source file, a signed copy), but Folio gave no sign they were there and no way to get them out.
Change
When a PDF has files attached at the document level, the sidebar gets a Files tab next to Pages, Outline and Notes. It lists each file with its name and description, and the button on a row saves that file exactly as it was embedded. PDFs without attachments show no extra tab.
The names, descriptions and contents come from the PDF, so they are treated as untrusted:
Files attached to a page as annotations, and reading attached PDFs in their own tabs, are left out, as agreed in the issue. The README's "Read and navigate" list has one new line.
Two things I left for your judgement rather than deciding here:
invoice.pdf.exeis saved under that name without a warning. The reader always picks the location in the save dialog and nothing is opened. I didn't check whether Windows or macOS mark the saved file as downloaded.Issue or approval
Refs #53. Scope approved in #53 (comment) ("lists attachments embedded at the document level and lets the reader save one. A small PDF fixture can verify that the saved bytes match the attachment.")
How I checked it
src/attachments.test.tsbuilds a small PDF with pdf-lib and checks, against real pdf.js, the listed names and descriptions, that each file's bytes come back identical (a buffer with every byte value), the list and size limits, and the name cleanup.scripts/smoke-attachments.mjs, called fromcheckReaderTools) opens a PDF with a binary file, a text file and a file with no extension, saves each one through the Files tab, and compares the saved files with the originals byte for byte and the offered names with the listed ones. It also checks that a PDF without attachments has no Files tab.npx tsc --noEmit,npm test, and the new smoke check with a hidden window.Not checked: Windows and macOS by hand (CI only), and the save dialog itself, which the smoke check bypasses by setting the save path.
Before and after, the same PDF with three attached files:
Screenshots will be attached here before this is marked ready for review.
Written and tested with Claude Fable 5.2 in Claude Code.
🤖 Generated with Claude Code