feat: configurable PDF export — page size, margins, orientation, page numbers - #7
Merged
Merged
Conversation
… numbers Adds a 'PDF export' section to Settings exposing the knobs the underlying webContents.printToPDF call already supports, plus a couple of nice-to-haves: - Page size: A4 / Letter / Legal / A3 / A5 / Tabloid (was hardcoded A4) - Margins: Default / Narrow / None preset (was hardcoded Default) - Landscape orientation toggle - Print background toggle (lets users force plain-white if they want) - Page numbers (X / Y centred footer) — automatically widens vertical margins to >=0.5in when on so the footer doesn't overlap content Persisted to localStorage under marky:settings.pdf so each user only sets their preferences once. exportToPdf() reads them at export time, so the existing Ctrl+E shortcut and command-palette entry continue to 'just work'. preferCSSPageSize is now disabled when page numbers are on — the @page CSS rule otherwise overrides Chromium's runtime header/footer area.
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.
Summary
Surfaces the print knobs the existing
webContents.printToPDFcall already supports (the pipeline was hardcoded to A4 + default margins) and adds two genuinely new things: landscape orientation and an optional "X / Y" page-number footer. All settings live under a new PDF export section in the existing Settings modal and persist tolocalStorageso each user only configures once.Controls
Wiring
src/shared/types.ts—ExportPdfOptionsgainslandscape+displayPageNumbers;pageSizewidens to the six Electron-supported sizes via a newPdfPageSizetype.src/main/ipc/pdf.ts— threads new options intoprintToPDF. WhendisplayPageNumbersis on we disablepreferCSSPageSize(the@pagerule otherwise wins over Chromium''s runtime footer area) and inject minimal header (<div></div>) + footer (centred InterpageNumber / totalPages) templates.src/renderer/src/store/settings.ts— addspdf: PdfPrefswith a singlesetPdf(partial)mutator; persisted alongside the existing theme/syncScroll/showLineNumbers fields.src/renderer/src/lib/exportPdf.ts— readsuseSettings.getState().pdfand threads it into the IPC call. Ctrl+E and the command-palette entry continue to "just work".src/renderer/src/components/SettingsModal.tsx— newPdfExportSectionrendered between About and AI provider, using the existingField/Toggle/Selectprimitives so it matches the rest of the modal.Tests
src/renderer/src/store/settings.test.tscovers defaults,setPdfpartial-merge semantics, and localStorage round-trip.vitest.setup.tsstubswindow.matchMedia(jsdom doesn''t ship it) so any store that probesprefers-color-schemeat import time is safe to load in tests.vitest.config.ts > test.setupFiles.Test plan
npm test,npm run lint,npm run typecheck,npm run format:check,npm run buildall pass locallyOut of scope