Add Share as PDF and Share Note File to share menu#1918
Open
gjouret wants to merge 1 commit intoglushchenko:masterfrom
Open
Add Share as PDF and Share Note File to share menu#1918gjouret wants to merge 1 commit intoglushchenko:masterfrom
gjouret wants to merge 1 commit intoglushchenko:masterfrom
Conversation
Adds two new sharing options to the NSSharingServicePicker: - **Share as PDF**: Renders the note to HTML via MPreviewView.buildPage(), loads it in a headless WKWebView, measures full document height for multi-page support, then creates a PDF via WKWebView.createPDF(). The PDF is saved to a temp file and shared via the system share sheet. - **Share Note File**: Shares the note's file URL directly (works for both plain .md files and .textbundle packages) via the system share sheet. New file: PDFExporter.swift — async WKWebView-based PDF renderer, following the same pattern as the existing Printer.swift helper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
WKWebView.createPDF(), and opens the system share sheet with the PDF file.mdfiles and.textbundlepackages)PDFExporterhelper class (follows the sameWKWebView+WKNavigationDelegatepattern as the existingPrinter.swift)buildPage()previously skippedloadImages()whenprint: true, relying onassignBase64Images()which only matched standardsyntax — images inside markdown tables were missed. Removed the!printguard soloadImages()copies image files to the temp bundle for all export modes.Implementation Details
MPreviewView.buildPage()to generate HTML, then loads it in a headlessWKWebViewdocument.body.scrollHeightand the web view is resized to the full content height before callingcreatePDF()— this ensures multi-page documents render completelyPDFExporteris retained via a static property onEditorViewControllerto prevent deallocation during async renderingNSSharingServicePickeralongside Web, Copy Plain Text, and Copy HTMLloadImages()now runs for print/PDF export mode too — it copies image files from the note'sassets/directory to the temp bundle so the headless WKWebView can resolve relative<img src>pathsTest plan
.mdnote — verify the file URL is shared.textbundlenote — verify the bundle directory is shared🤖 Generated with Claude Code