You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Root Cause:
The current PDF export architecture uses \html2canvas\ and \jsPDF\ to capture the entire rendered markdown document as a large raster image. This image is then sliced and placed into a PDF document. Because it is rasterized, text in the PDF is unselectable, fuzzy, and appears pixelated or blurred when zoomed in.
Implementation Approach:
To fix this while keeping the legacy raster export safe, I've split the PDF export options:
PDF (Vector): This replaces the primary 'PDF' export button and invokes native browser printing (\window.print()). A new @media print\ CSS block was added to \styles.css\ that hides the editor pane, header, and toolbars, and makes the preview pane take up the full print document. This outputs a true vector PDF with crisp, selectable text.
PDF (Legacy Image): The old \html2canvas\ + \jsPDF\ logic was preserved under a new 'Legacy PDF' dropdown option. It acts as a fallback for browsers where printing behaves poorly or if users specifically want a raster image inside a PDF wrapper.
Before/After Behavior:
Before: Exporting a PDF resulted in a large file containing a single raster image where text was blurry.
After: Exporting a PDF via the new default method opens the native print dialog, generating a fast, vector-based PDF with perfectly crisp and selectable text. Diagrams and MathJax still render correctly inside the preview block prior to printing.
Connected native \window.print()\ to the existing \exportPdf\ click listener.
Ensured \exportPdfRaster\ logic retains the older complex multi-pass rendering.
Limitations or trade-offs:
The new vector PDF relies on browser-native pagination during printing instead of manual height calculation. This is generally more robust for text but might occasionally page-break awkwardly inside large code blocks depending on browser heuristics.
Confirmation: Unrelated export features (HTML export, PNG export, Markdown preview) were not broken.
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
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.
Fixes #195
Root Cause:
The current PDF export architecture uses \html2canvas\ and \jsPDF\ to capture the entire rendered markdown document as a large raster image. This image is then sliced and placed into a PDF document. Because it is rasterized, text in the PDF is unselectable, fuzzy, and appears pixelated or blurred when zoomed in.
Implementation Approach:
To fix this while keeping the legacy raster export safe, I've split the PDF export options:
Before/After Behavior:
Testing Performed:
Limitations or trade-offs:
Confirmation: Unrelated export features (HTML export, PNG export, Markdown preview) were not broken.