Skip to content

Start printing on the paper of the document - #711

Merged
andiwand merged 1 commit into
mainfrom
fix/print-paper
Oct 10, 2026
Merged

andiwand merged 1 commit into
mainfrom
fix/print-paper

Conversation

@andiwand

@andiwand andiwand commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #710. The print dialog always started on the default paper of the printer, in portrait. An A4 document started on Letter, and a slide started on a portrait sheet.

Change

  • PageSize (new, pure Kotlin): a page size in mils, made from a core Measure (in, cm, mm, pt, pc, px). It matches A3, A4, A5, Letter, Legal and Tabloid within 2%, which keeps A4 and Letter apart.
  • CoreLoader: reads the page size of a text, presentation or drawing document. For text it uses TextRoot.pageLayout(), otherwise the first slide or page. The document is opened once, for this and for the editing check, so an editable format gets no extra decode. The value goes to LoadedDocument and is parcelled with it.
  • PrintingManager: gives PrintManager.print a MediaSize for the paper and orientation. For a size without a standard paper, such as a 4:3 slide, it gives only UNKNOWN_LANDSCAPE or UNKNOWN_PORTRAIT. For a PDF printed from its file, PdfRenderer reads the size of the first page.

The print framework uses these attributes only as the start values. If the printer does not have the paper, the dialog falls back to the paper of the printer, and the user can still change it.

Verification

  • PageSizeTest (5 tests) and the DocumentParcelTest round trip (6 tests, on the emulator) pass. spotlessCheck and lintProDebug pass.
  • Pixel 6 Pro emulator, Pro debug build, print dialog with "Save as PDF":
File Page Dialog before Dialog now
Casio_WVA-M650-7AJF.pdf A4 portrait Letter, portrait ISO A4, portrait
speisekarte_helmarts.pdf A4 landscape Letter, portrait ISO A4, landscape
style-various-1.pdf Letter Letter, portrait Letter, portrait
style-various-1.odp 28 × 21 cm Letter, portrait Letter, landscape; 6 sheets for 6 slides
file-sample_100kB.odt A4 Letter, portrait ISO A4, portrait
sample.odg A4 Letter, portrait ISO A4, portrait; 3 sheets for 3 pages
file_example_XLSX_10.xlsx none Letter, portrait Letter, portrait

I read the "before" column from #710's emulator run (Letter for the Casio PDF) and from the framework default; I did not rerun every row on the old build.

The print dialog always started on the default paper of the printer,
in portrait. An A4 document printed on Letter, and a slide printed on a
portrait sheet.

CoreLoader now reads the page size of a text, presentation or drawing
document from the core. It opens the document once, for this and for
the editing check. For a PDF printed from its file, PdfRenderer reads
the size of the first page. PrintingManager gives the print framework
the matching standard paper and orientation. For a size that has no
standard paper, it gives only the orientation.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KNpfqA2jL1iVM1Wirf7njH
@andiwand
andiwand merged commit 0d608cc into main Oct 10, 2026
2 checks passed
@andiwand
andiwand deleted the fix/print-paper branch October 10, 2026 09:12
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