Closed Bug 1631452 Opened 5 years ago Closed 4 years ago

Support a 'pages per sheet' option in print preview

Categories

(Core :: Print Preview, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
83 Branch
Tracking Status
firefox83 --- fixed

People

(Reporter: jwatt, Assigned: dholbert)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [print2020_v84])

Attachments

(8 files, 2 obsolete files)

(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/plain
Details
(deleted), application/pdf
Details
(deleted), application/pdf
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details

The new print preview design calls for allowing the user to select the number of pages they want per sheet and to be able to see the result of their selection in the preview. We will need to implement support for this at the platform level.

We should consider this together with the @page bug 851441 since that will involve reworking the same code ( https://searchfox.org/mozilla-central/source/layout/generic/nsPageSequenceFrame.cpp ).

I'll plan on taking this one.

Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Depends on: 1652278

I'm not actually renaming these APIs yet, to avoid bitrotting folks & shaking
things up too much, but we should consider renaming them soon. This patch just
makes the subtlety and pages-vs-sheets distinction a bit clearer in the
documentation.

Depends on D86797

Attached file dummy patch for testing (DO NOT LAND) (deleted) —

Here's the patch I'm using to test this feature locally -- (ab)using an about:config pref to set the default pages-per-sheet value (which then ends up being the pages-per-sheet value that we use).

To test, try applying the patch stack and this patch on top, and running:

./mach run --setpref "print.default_pps=9" https://www.mozilla.org/en-US/MPL/2.0/

These patches are mostly-complete. The attached patch stack adds a new attribute on nsIPrintSettings called numPagesPerSheet pref that will, for now, let you print with 1, 4, 9, or 16 pages per sheet. (support for 2 and 6 still coming)

Things that are currently missing:

  • Support for 2 and 6 as options for pages-per-sheet, as noted above (these are the ones that will typically require rotating the paper's orientation, depending on paper size, so they're a bit more subtle).
  • Working properly with page ranges (including/excluding pages)
  • Carrying the value forward into the native dialog's settings (if the user picks some pages-per-sheet value in our new UI and then chooses "print using system dialog" and expects their choice to be carried forward into that dialog -- I'm pretty sure this doesn't work yet, at least).
Depends on: 1660166
Depends on: 1660294

Comment on attachment 9169552 [details]
Bug 1631452 part 0: Directly initialize nsSharedPageData member-var, and adjust its documentation. r?TYLin

Revision D86797 was moved to bug 1660294. Setting attachment 9169552 [details] to obsolete.

Attachment #9169552 - Attachment is obsolete: true

Comment on attachment 9169553 [details]
Bug 1631452 part 1: Tag the page-number-related attributes in nsIWebBrowserPrint as potentially needing a rename (since they're actually about sheet numbers). r?TYLin

Revision D86798 was moved to bug 1660294. Setting attachment 9169553 [details] to obsolete.

Attachment #9169553 - Attachment is obsolete: true
Attachment #9169554 - Attachment description: Bug 1631452 part 2: Give nsIPrintSettings a "numPagesPerSheet" attribute. r?TYLin → Bug 1631452 part 1: Give nsIPrintSettings a "numPagesPerSheet" attribute. r?TYLin
Attachment #9169555 - Attachment description: Bug 1631452 part 3 WIP: Add the pages-per-sheet info to nsSharedPageData and use it to control the number of pages that end up on a PrintedSheetFrame. → Bug 1631452 part 2 WIP: Add the pages-per-sheet info to nsSharedPageData and use it to control the number of pages that end up on a PrintedSheetFrame.
Whiteboard: [print2020] → [print2020_v82]
Depends on: 1661868
Whiteboard: [print2020_v82] → [print2020_v83]
Blocks: 1668400
Attachment #9169554 - Attachment description: Bug 1631452 part 1: Give nsIPrintSettings a "numPagesPerSheet" attribute. r?TYLin → Bug 1631452 part 1: Give nsIPrintSettings a "numPagesPerSheet" attribute. r=TYLin
Attachment #9169555 - Attachment description: Bug 1631452 part 2 WIP: Add the pages-per-sheet info to nsSharedPageData and use it to control the number of pages that end up on a PrintedSheetFrame. → Bug 1631452 part 2: Add the pages-per-sheet info to nsSharedPageData and use it to control the number of pages that end up on a PrintedSheetFrame. r?TYLin,mattwoodrow
Blocks: 1669905

Here's an example of the output that this produces (in PDF form).

I generated this by applying this patch stack as well as the "dummy patch for testing", and then running
./mach run --setpref "print.default_pps=4" https://www.mozilla.org/en-US/MPL/2.0/
...and setting the following prefs all to 25:

print.printer_Mozilla_Save_to_PDF.print_unwriteable_margin_bottom
print.printer_Mozilla_Save_to_PDF.print_unwriteable_margin_left
print.printer_Mozilla_Save_to_PDF.print_unwriteable_margin_right
print.printer_Mozilla_Save_to_PDF.print_unwriteable_margin_top

...and then printing.

Without setting those prefs, we have the default behavior which has 0 unwriteable margins, which still produces fairly-reasonable output (see the attachment after this one), but the pages are smooshed directly against each other (which really means the footers/headers are smooshed together). I'll attach another PDF to demonstrate that problem next, and I'll spin off a separate bug for that (for which I think the only real solution is having some nonzero defaults for the unwriteable margins).

(I filed bug 1669910 on the fact that our zero-sized unwriteable margins produce kinda smooshed looking output [regardless of whether you're using pages-per-sheet, really].)

Blocks: 1670068
Attachment #9180946 - Attachment description: Bug 1631452 part 3: Add subtests for pages-per-sheet in print-preview mode. → Bug 1631452 part 3: Add subtests for the "pages-per-sheet" print feature. r?TYLin

These tests are modified copies of the previous patch's subtest for a
4-pages-per-sheet scenario.

Depends on D93185

Whiteboard: [print2020_v83] → [print2020_v84]
Pushed by dholbert@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a4cdd6ce7b4b part 1: Give nsIPrintSettings a "numPagesPerSheet" attribute. r=TYLin https://hg.mozilla.org/integration/autoland/rev/795a4e8543b3 part 2: Add the pages-per-sheet info to nsSharedPageData and use it to control the number of pages that end up on a PrintedSheetFrame. r=TYLin,mattwoodrow https://hg.mozilla.org/integration/autoland/rev/951bffe50396 part 3: Add subtests for the "pages-per-sheet" print feature. r=TYLin https://hg.mozilla.org/integration/autoland/rev/b46e187e3c2e part 4: Add more subtests for pages-per-sheet (for values 9 and 16). r=TYLin https://hg.mozilla.org/integration/autoland/rev/dbaa8eaf2753 part 5: Add some windows-specific fuzz to pages-per-sheet tests, to account for page-margins not being reliably respected in test_printpreview.xhtml. r=TYLin
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: