Add .spd export commands (PNG, PDF) - #140
Merged
Merged
Conversation
.spd equivalents of the existing .note export commands: - export-atelier-as-png: writes the flattened composite image (SupernoteAtelier.toCompositeImage()) as a PNG attachment. - export-atelier-as-pdf: wraps that same image in a single-page PDF, built directly with pdf-lib (added as a plugin dependency, matching the version already pinned in the supernote-typescript submodule) rather than through supernote-typescript's createPdfContext/addPdfPage, which are built around .note's per-page recognized-text layer that .spd has no equivalent of. No .spd equivalent of export-note-as-markdown (the .note command that writes markdown only, no image): that one exists for .note because a PageTextProcessor can still enrich the OCR/recognized text without any image attachment. .spd has no text at all, so a markdown export would have nothing to write without also rasterizing an image. Refactors renderAtelierCompositeDataUrl() out of atelierView.ts (private there, shared by the view and the embed) so the new export commands reuse the same open-and-flatten logic instead of duplicating it. One more item off #138.
5 tasks
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
Next slice of #138:
.spdequivalents of the existing.noteexport commands.export-atelier-as-png— writes the flattened composite image (SupernoteAtelier.toCompositeImage()) as a PNG attachment.export-atelier-as-pdf— wraps that same image in a single-page PDF. Built directly withpdf-lib(added as a plugin dependency, matching the version already pinned in thesupernote-typescriptsubmodule) rather than throughsupernote-typescript'screatePdfContext/addPdfPage, which are built around.note's per-page recognized-text layer —.spdhas no equivalent of that, so reusing those would mean threading a bunch of irrelevant text-layer machinery through for nothing. Same page-sizing convention as.note's PDF export (300dpi assumed source density → 72pt/inch)..spdequivalent ofexport-note-as-markdown(the.notecommand that writes markdown only, no image) — that one exists for.notebecause aPageTextProcessorcan still enrich the OCR/recognized text without an image attachment..spdhas no text at all, so a markdown-only export would have nothing to write.Also refactors
renderAtelierCompositeDataUrl()out to be exported fromatelierView.ts(previously private there) so these new commands reuse the same open-and-flatten logic that the view (#137) and embed (#139) already use, instead of duplicating it.Test plan
npm run buildsucceedsnpm test— all 95 existing tests still passnpm run lint— no new warnings/errorsembedPng/addPage/drawImage) againstsupernote-typescript/tests/input/real-device.spdoutside the plugin — produces a valid single-page PDF sized correctly from the composite image