Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 2.11 KB

README.md

File metadata and controls

32 lines (24 loc) · 2.11 KB

PdfCraft web build

Generated by scripts/build-pdfcraft-web.sh; don't edit by hand.

File
boot.js Loaded by the editor's iframe (templates/frame.php); imports the two files below by content-hashed name
pdfcraft-web-<hash>.js wasm-bindgen glue (ES module)
pdfcraft-web-<hash>.wasm PdfCraft, built from storytold/pdfcraft with patches/pdfcraft-nextcloud.patch (which only removes the ArtCraft marks)
PDFCRAFT-* PdfCraft's licenses (MIT OR Apache-2.0) and the attributions for the fonts and icons compiled into it

Embedding bridge

Part of PdfCraft since storytold/pdfcraft#842. Started with ?host=parent inside an iframe, PdfCraft talks to its parent window with postMessage. It only accepts messages from the parent window on its own origin, and only sends to that origin. Every message is a plain object with a type:

Message Direction Fields Meaning
pdfcraft:ready PdfCraft → parent version The app is listening; send files now.
pdfcraft:open parent → PdfCraft name, bytes (ArrayBuffer or Uint8Array) Open this PDF in a tab.
pdfcraft:save PdfCraft → parent name, saveAs (boolean), bytes (transferred ArrayBuffer) The user saved; the parent stores the file and reports success or failure itself.
pdfcraft:dirty PdfCraft → parent dirty (boolean) Unsaved work appeared or went away (any tab).
pdfcraft:failed PdfCraft → parent error The app couldn't start (for example, no WebGL).

With ?host=parent, an optional &author=<name> signs the user's comments with that name unless they set one in PdfCraft's preferences.

Without ?host=parent, Save downloads the file as usual.

PdfCraft also asks the browser to confirm leaving the page while it has unsaved changes. The editor page removes the frame before it leaves on purpose (after asking the user itself), so they aren't asked twice.