RavishaHesh / PDFJsAnnotations

Wrapper for PDF JS to add annotations
MIT License
322 stars 98 forks source link

localstorage #55

Open jesesqui opened 2 years ago

jesesqui commented 2 years ago

I'm trying to do an autosave with localstorage and it works assigning the key and the value like this: var pdf = new PDFAnnotate("pdf-container", "my_document.pdf", { onPageUpdated(page, oldData, newData) { localStorage.setItem(page, JSON.stringify(newData)); console.log("page "+ page, oldData, newData); }, and then with a button to load the localstoage but this last one without success, could you guide me on how to achieve this

var canvas = document.getElementById('pdf-container'), document.getElementById("btnLoad").onclick = function () { var idt = localStorage.getItem(1) || null; if (idt !== null) { var data = JSON.parse(idt); canvas.putImageData(idt, 0, 0); }

localstorage