Skip to content

Render PDFs inline in the browser tab#8211

Draft
GerardPaligot wants to merge 2 commits intodevelopfrom
feature/gerard/render-pdfs-inline
Draft

Render PDFs inline in the browser tab#8211
GerardPaligot wants to merge 2 commits intodevelopfrom
feature/gerard/render-pdfs-inline

Conversation

@GerardPaligot
Copy link
Copy Markdown
Contributor

Task/Issue URL: https://app.asana.com/1/137249556945/task/1213892682193779

Description

Renders PDF files inline in the browser tab instead of triggering a file download, using AndroidX pdf-viewer-fragment.
When the WebView intercepts a PDF download (application/pdf MIME type or .pdf URL), the file is downloaded to internal cache, validated with %PDF- magic bytes, and displayed in a themed PDF viewer overlaid on the browser tab.

Steps to test this PR

Inline PDF rendering

  • Navigate to a URL that serves a PDF (e.g. search for "sample pdf" on DuckDuckGo and tap a .pdf link)
  • Verify the omnibar shows a loading progress bar while the PDF downloads
  • Verify the PDF renders inline in the browser tab (not a file download prompt)
  • Verify you can scroll through multi-page PDFs
  • Press back — verify it dismisses the PDF and shows the previous web page

Fallback to download

  • On a device below Android 12, verify all PDFs trigger standard download

Cancellation on navigation

  • Start loading a large PDF
  • While the progress bar is still showing, tap the omnibar and navigate to a different URL
  • Verify the PDF does NOT appear after navigation — the download was cancelled (PDF download cancelled visible in logcat)

Process death recovery

  • Open a PDF inline, then kill the app process
  • Restore the app — press back and verify it navigates home (instead of showing a blank screen)

Feature flag off

  • Disable the pdfViewer feature flag
  • Verify PDF links trigger standard file download

UI changes

Before After
!(Upload before screenshot) (Upload after screenshot)

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant