Skip to content

Comments

Add comprehensive print CSS for clean note printing#1757

Open
jacksbox-cassandra wants to merge 1 commit intonextcloud:mainfrom
jacksbox-cassandra:notes/print-css-MR
Open

Add comprehensive print CSS for clean note printing#1757
jacksbox-cassandra wants to merge 1 commit intonextcloud:mainfrom
jacksbox-cassandra:notes/print-css-MR

Conversation

@jacksbox-cassandra
Copy link

This PR implements comprehensive print CSS for Nextcloud Notes to ensure clean printing without UI elements.

Changes Made

Print CSS Enhancement (css/notes.css)

  • Hide UI elements (header, navigation, action buttons, sidebars) when printing
  • Optimize typography with proper fonts, sizing, and spacing for print media
  • Add page break controls for better pagination of long content
  • Style tables, code blocks, and images appropriately for print
  • Ensure high contrast black text on white background
  • Add proper margins and formatting for professional document appearance

Playwright Test (playwright/e2e/print.spec.ts)

  • Test PDF generation works correctly and produces non-empty output
  • Verify note content and titles appear correctly in generated PDFs
  • Test that UI elements are properly hidden when print media is applied
  • Use pdf-parse library to validate PDF text content programmatically

Features

Print Optimization:

  • ✅ Headers, navigation, and toolbars hidden
  • ✅ Note content optimized for readability on paper
  • ✅ Proper page breaks for long notes
  • ✅ Professional typography with serif fonts
  • ✅ Code blocks and tables formatted appropriately
  • ✅ Images scale to fit page width

Quality Assurance:

  • ✅ Comprehensive Playwright tests
  • ✅ PDF content validation
  • ✅ All ESLint and StyleLint checks passing
  • ✅ Cross-browser print media testing

Testing

The implementation includes comprehensive tests that verify:

  1. PDF generation produces valid, non-empty output
  2. Note titles and content appear correctly in printed documents
  3. UI elements (navigation, headers, buttons) are hidden during printing
  4. Print media queries work correctly across different browsers

Related Issue

Fixes #179

Screenshots

To test locally:

  1. Create or open a note in Nextcloud Notes
  2. Use browser print function (Ctrl+P / Cmd+P)
  3. Select 'Save as PDF' to see the clean print layout
  4. Verify only note content appears without UI elements

The print output will show a clean, professional document with only the note content, properly formatted for reading on paper.

- Hide UI elements (header, navigation, action buttons) in print mode
- Optimize typography and layout for better readability on paper
- Add proper page break controls and margin handling
- Include @media print rules for tables, code blocks, and images
- Ensure note content is properly formatted with readable fonts
- Add Playwright tests to verify PDF generation and content validation
- Verify UI elements are correctly hidden in print media

Fixes nextcloud#179

The print CSS ensures that:
- Only note content appears when printing (no headers/sidebars)
- Text is optimized for print with proper fonts and sizing
- Page breaks are handled appropriately for long content
- Tables and code blocks are properly formatted
- Images scale correctly to fit pages

Tests verify that:
- PDFs are generated successfully and contain note content
- Note titles appear correctly in printed output
- UI elements are hidden when print media is applied
- PDF content matches the actual note text
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.

CSS media query for printing style

1 participant