Skip to content

Conversation

@cheapsteak
Copy link
Contributor

@cheapsteak cheapsteak commented May 4, 2017

No UI (should be the easy part, hacked this in to scratch an itch)

In browser console:

Tabula.pdf_view.save()

Saves to localStorage

Tabula.pdf_view.load(id) // id increments from 1

Should also be trivial to export save-files from the JSON in localStorage

@jeremybmerrill
Copy link
Member

@cheapsteak Whoa, this is awesome! Building the ability to save and load templates has been on the wish list for AGES. (see #483, #93). We'll take a look at your PR; this is a great start.

@jeremybmerrill
Copy link
Member

Initially I had imagined saving templates to disk and then re-uploading them. But your idea of saving the template to localStorage is a brilliant one, since I think it'll remove a few steps from the workflow. (Occasionally I can envision wanting to download a template and either save it for later or email it to someone, so we'll want the download/upload workflow. But probably the vast majority of users will want to save a template and use it again a minute later; for that, the localStorage method would work great.)

@cheapsteak
Copy link
Contributor Author

happy to hear it'll help :)

a quick solution to enabling downloading a saved state as a file would be to run this in the console

window.location.href = window.encodeURI('data:application/download;charset=utf-8,' + Tabula.pdf_view.serializeSelections());

that should trigger a download

then to load it,

Tabula.pdf_view.loadSerializedSelections(JSON.parse("string contents of the file that was previously downloaded (it's a json file)"))

@jeremybmerrill
Copy link
Member

Awesome. I will take a look and try to figure out how to fit this in. Not sure when I'll get to it, but it's on my todo list.

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.

3 participants