Optimization: PDF Compression & Size Reduction on Export#12
Optimization: PDF Compression & Size Reduction on Export#12Votienduong2208 wants to merge 2 commits into
Conversation
- Add ExportProfile type (lossless | low-size) to domain/types - Add exportProfile to UiState and setExportProfile action to pdfStore - Pass exportProfile through export worker request (protocols.ts, exportPdf.ts, export.worker.ts) - Implement PDF compression in PdfLibWriter with saveWithProfile method - 'low-size' profile uses useObjectStreams, objectsPerStream for smaller output - Add export profile selector (Lossless vs Low Size) to ExportDialog UI - Wire up profile selection in App.tsx handleExport Closes YurMil#10
There was a problem hiding this comment.
Code Review
This pull request introduces an "Export profile" feature, allowing users to choose between "Lossless" (best quality) and "Low size" (compressed) options when exporting PDFs. This involves updating the PdfLibWriter adapter, the UI components (ExportDialog, App), the state store, and the background export worker to pass and handle the selected ExportProfile. Feedback highlights a critical issue in App.tsx where a second call to runExport inside handleOpenViewer was missed during the signature update, which will lead to a runtime crash. Additionally, a style improvement was suggested in protocols.ts to move the inline import of ExportProfile to the top of the file.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| snapshot.setJob('export', { status: 'running', progress: 5, message: 'Preparing export...' }); | ||
| try { | ||
| const files = await runExport(snapshot, mode, snapshot.ui.exportFileName, (progress, message) => { | ||
| const files = await runExport(snapshot, mode, snapshot.ui.exportFileName, snapshot.ui.exportProfile, (progress, message) => { |
There was a problem hiding this comment.
While this call to runExport has been correctly updated to include snapshot.ui.exportProfile, the other call to runExport inside handleOpenViewer (around line 408) was missed. It still passes only 4 arguments:
const files = await runExport(snapshot, { kind: 'workspace' }, snapshot.ui.exportFileName || 'pdf-master-viewer', (progress, message) => { ... })Because the signature of runExport was changed to require exportProfile as the 4th argument, passing the progress callback as the 4th argument will cause onProgress to be undefined inside runExport. This will result in a runtime crash (TypeError: onProgress is not a function) when the worker sends progress updates.
Please update the call in handleOpenViewer to pass the export profile (e.g., snapshot.ui.exportProfile or 'lossless').
| name: string; | ||
| } | ||
|
|
||
| import type { ExportProfile } from '@/domain/types'; |
There was a problem hiding this comment.
The import of ExportProfile is placed in the middle of the file. According to standard TypeScript style guides (such as ESLint's import/first rule), all import statements should be at the top of the file. Please remove this inline import and add ExportProfile to the existing group import from @/domain/types at the top of the file (line 1).
Summary
Adds PDF compression and size reduction option on export with two profiles:
Changes
lossless|low-size) to domain/typesexportProfileto UiState andsetExportProfileaction to pdfStoreexportProfilethrough export worker request chainPdfLibWriterwithsaveWithProfilemethoduseObjectStreams,objectsPerStreamfor smaller outputCloses #10