Skip to content

[api-minor] Support annotation flattening in extractPages (bug 2075337) - #22448

Open
calixteman wants to merge 4 commits into
mozilla:masterfrom
calixteman:flatten-extract-pages
Open

calixteman wants to merge 4 commits into
mozilla:masterfrom
calixteman:flatten-extract-pages

Conversation

@calixteman

Copy link
Copy Markdown
Contributor

Reuse the save path to flatten extracted pages. Remap pending form edits to copied annotations and reload with the encryption source's password. Rebuild the PDF to discard the unflattened revision.

sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Viewer preview

Commit b9e993a (build logs).

Viewer Build Preview
Modern (gulp generic) ✅ viewer.html
Legacy (gulp generic-legacy) ✅ viewer.html

Previews are removed when the PR closes and may be pruned after 30 days without an update.

@codecov-commenter

codecov-commenter commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.16519% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.63%. Comparing base (b600aec) to head (b9e993a).

Files with missing lines Patch % Lines
src/core/flattener.js 95.45% 25 Missing ⚠️
src/core/core_utils.js 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #22448      +/-   ##
==========================================
+ Coverage   90.57%   90.63%   +0.06%     
==========================================
  Files         276      277       +1     
  Lines       68671    69314     +643     
==========================================
+ Hits        62197    62824     +627     
- Misses       6474     6490      +16     
Flag Coverage Δ
fonttest 9.09% <0.00%> (-0.01%) ⬇️
unittest 64.08% <96.16%> (+0.98%) ⬆️
unittestcli 61.88% <96.16%> (+1.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed

codspeed Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 13.7%

⚡ 1 improved benchmark
✅ 87 untouched benchmarks
⏩ 174 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ Autolinker.processLinks: 10 links in each of 1000 text items 64.9 ms 57.1 ms +13.7%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing calixteman:flatten-extract-pages (b9e993a) with master (b600aec)

Open in CodSpeed

Footnotes

  1. 174 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Add flatten and intent options to draw supported annotation appearances
into page content. Use print or display visibility. Keep the widgets and
the interactive annotations.

Android 14's PdfRenderer calls PDFium without FPDF_ANNOT [1].

[1] https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-14.0.0_r1/libs/hwui/jni/pdf/PdfRenderer.cpp
With `flatten: true`, also draw the widgets, generating their appearances
from the stored values, and remove the ones hidden for the intent. Prune
the removed fields from the AcroForm, and remove it when no page widget
remains, unless it declares signatures. Add a "non-forms" value to keep the
form fields.
In a flat parent tree, replace the OBJR of a flattened annotation with a
marked-content reference to its drawing in the page content. For other
readable parent trees, only remove the OBJR.
Reuse the save path to flatten extracted pages. Remap pending form edits
to copied annotations and reload with the encryption source's password.
Rebuild the PDF to discard the unflattened revision.
@calixteman
calixteman force-pushed the flatten-extract-pages branch from 7850e82 to b9e993a Compare November 9, 2026 21:07
sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Nov 9, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants