Skip to content

Add .spd export commands (PNG, PDF) - #140

Merged
philips merged 1 commit into
mainfrom
spd-export-commands-issue-138
Jul 28, 2026
Merged

Add .spd export commands (PNG, PDF)#140
philips merged 1 commit into
mainfrom
spd-export-commands-issue-138

Conversation

@philips-clanker

@philips-clanker philips-clanker commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Next slice of #138: .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 — .spd has 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).
  • 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 an image attachment. .spd has no text at all, so a markdown-only export would have nothing to write.

Also refactors renderAtelierCompositeDataUrl() out to be exported from atelierView.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 build succeeds
  • npm test — all 95 existing tests still pass
  • npm run lint — no new warnings/errors
  • Verified the PNG→PDF path (embedPng/addPage/drawImage) against supernote-typescript/tests/input/real-device.spd outside the plugin — produces a valid single-page PDF sized correctly from the composite image
  • Not yet manually verified inside a running Obsidian vault (no automated Electron/GUI harness for this repo yet, same as Prototype .spd (Supernote Atelier) file support #137/Add ![[file.spd]] embed support #139)

.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.
@philips
philips merged commit 575d94e into main Jul 28, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants