Repository navigation
Print a PDF from its own file - #710
Merged
Merged
Conversation
Printing always used the WebView, so a PDF printed as the HTML that the core renders. The print framework got the viewer layout, and the pages broke across sheets. The overload that prints a file through PdfDocumentAdapter had no caller. A PDF now prints from the cached copy of the file. A PDF with a password still prints the page, because the print framework cannot open it. A PDF with unsaved marks also prints the page, because the file does not have the marks yet. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KNpfqA2jL1iVM1Wirf7njH
This was referenced Oct 10, 2026
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.
A user reported that a PDF printed from the app has the wrong layout.
ACTION_PRINTalways prints the WebView, so a PDF printed as the HTML that the core renders: the grey viewer background, pages broken across sheets, and a landscape page shrunk onto a portrait sheet.PrintingManager.print(activity, pdfFile)prints a file throughPdfDocumentAdapter, but nothing called it.Change
PrintingManager.printsOriginal: a PDF prints from its file if it has no password and no unsaved marks.DocumentFragment.printableOriginal(): the cached copy of such a PDF. After a save the document reloads, so the cached copy holds the saved marks.MainActivity: the print action uses that file if there is one. All other documents print the WebView, as before.The page view still prints:
The core fix for printing the page view is opendocument-app/OpenDocument.core#1197. It also fixes slides, drawings and text pages with margins.
Verification
PrintingManagerTestcovers the four cases.spotlessCheckandcompileProDebugKotlinpass.Casio_WVA-M650-7AJF.pdf(9 A4 pages) shows "Page 1 of 9" in the print preview on Letter. Each sheet holds one full page. In desktop Chrome, the current core HTML of the same file prints on 10 sheets with pages split across them. I did not print the old path on the emulator.style-various-1.odpstill prints through the WebView.I did not print to a real printer.