diff --git a/CHANGELOG.md b/CHANGELOG.md index 7981b7ea4..5c26a6ae3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ The release run heads these entries with the version and opens a fresh ## Unreleased +- A printed sheet drops our row/column ruler and is capped to the page width + rather than cut off at the right edge. Print only; the on-screen view is + unchanged. Towards #816. + - New `File::name()`: the file name on disk, the entry name inside an archive, or the name `File::from_memory(data, name)` was given. A named in-memory file gets the same name-derived type candidate a path does, so `notes.md` bytes diff --git a/src/odr/internal/html/frontend.cpp b/src/odr/internal/html/frontend.cpp index 246b67dc9..12ed40a13 100644 --- a/src/odr/internal/html/frontend.cpp +++ b/src/odr/internal/html/frontend.cpp @@ -112,6 +112,17 @@ body{margin:0;background:var(--odr-sheet-canvas)} .odr-sheet-sort:hover{background:var(--odr-sheet-wash-ruler)} .odr-sheet-sort::after{content:"\25BE";font-size:15px;line-height:1} .odr-sheet-sort-asc::after{content:"\25B4"} +/* Paper cannot scroll, so a sheet wider than the page is cut off; only + `!important` beats the inline column width. The ruler collapses rather than + `display:none`, which would take the cells out of their rows and shift every + column left. */ +@media print{ +.odr-sheet thead{display:none} +.odr-sheet-gutter{visibility:collapse;width:0} +.odr-sheet-row-header{visibility:collapse;padding:0;box-shadow:none} +.odr-sheet{max-width:100%} +.odr-sheet col{min-width:0!important} +} )css"; constexpr std::string_view spreadsheet_dark_css = R"css( diff --git a/test/src/html_test.cpp b/test/src/html_test.cpp index 7e63a3fd5..e76d7aad1 100644 --- a/test/src/html_test.cpp +++ b/test/src/html_test.cpp @@ -728,6 +728,24 @@ TEST(html, the_cell_budget_bounds_the_rows_by_the_width) { EXPECT_EQ(rendered(30, 3).rows, 5); } +// #816 +TEST(html, a_printed_sheet_drops_the_ruler_and_fits_the_page) { + const std::string sheet = + render("odr-public/ods/file_example_ODS_10.ods", HtmlConfig()); + + // on screen the sheet keeps its stated width and its ruler + EXPECT_NE(sheet.find("c"), FileType::xml); const HtmlService service = html::translate(file, HtmlConfig());