chore(client/pdf): basic reaction to annotations

This commit is contained in:
Elian Doran 2025-12-29 02:00:59 +02:00
parent 41bcf9524a
commit 5e42627bce
No known key found for this signature in database
3 changed files with 24 additions and 1 deletions

View File

@ -4,6 +4,7 @@ const build = new BuildHelper("packages/pdfjs-viewer");
async function main() {
build.copy("viewer", "web");
build.copy("src/custom.mjs", "web/custom.mjs");
build.copy("/node_modules/pdfjs-dist/build/pdf.mjs", "build/pdf.mjs");
build.copy("/node_modules/pdfjs-dist/build/pdf.worker.mjs", "build/pdf.worker.mjs");
}

View File

@ -0,0 +1,21 @@
document.addEventListener("webviewerloaded", async () => {
const app = PDFViewerApplication;
await app.initializedPromise;
app.eventBus.on("documentloaded", () => {
const storage = app.pdfDocument.annotationStorage;
storage.onSetModified = (data) => {
console.log("Annotations modified: ", all);
storage.resetModified();
};
const oldSetValue = storage.setValue;
storage.setValue = (key, value) => {
console.log("Setting annotation: ", key, value);
oldSetValue.call(storage, key, value);
}
});
});
console.log("Custom script loaded");

View File

@ -33,7 +33,8 @@ See https://github.com/adobe-type-tools/cmap-resources
<link rel="stylesheet" href="viewer.css" />
<script src="viewer.mjs" type="module"></script>
<script src="custom.mjs" type="module"></script>
<script src="viewer.mjs" type="module"></script>
</head>
<body tabindex="0">