3

I want to store pdf files client side in one of the HTML5 storages (indexedDB or localstorage) and then open them later with the adobe reader.

The scenario is as follows:

  1. The user visites my site and downloads a bunch of pdf's into a storage
  2. Later the user revisits the site and wants to view one of the pre downloaded pdf's.
    He chooses one of the stored pdf's and it gets rendered with the adobe reader (or the default pdf renderer).

Is this possible with pure html5/js or do i have to write a firefox extension?

Nick Russler
  • 4,608
  • 6
  • 51
  • 88
  • see this as a beginning point on HTML5 storage http://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage and also see http://stackoverflow.com/questions/4692245/html5-local-storage-fallback-solutions – Richard Chambers Sep 30 '14 at 15:18

2 Answers2

1

Create links with PDF type and base64 encoded data (representing the PDF binary)

<a href="data:[<mime type>][;charset=<charset>][;base64],<encoded data>">PDF name</a>

The base64 encoded content can be stored in HTML5 storage.

Warning: does not work for IE (excuses for security reasons).

Pavel Gatnar
  • 3,987
  • 2
  • 19
  • 29
1

You can use the data URI scheme (http://en.wikipedia.org/wiki/Data_URI_scheme).

Something like this, but with a PDF:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKBJREFUeNpiYBjpgBFd4P///wJAaj0QO9DEQiAg5ID9tLIcmwMYsDgABhqoaTHMUHRxpsGYBv5TGqTIZsDkYWLo6gc8BEYdMOqAUQeMOoAqDgAWcgZAfB9EU63SIAGALH8PZb+H8v+jVz64KiOK6wIg+ADEArj4hOoCajiAqMpqtDIadcCoA0YdQIoDDtCqQ4KtBY3NAYG0csQowAYAAgwAgSqbls5coPEAAAAASUVORK5CYII=

You can see this example at its original page: http://iconhandbook.co.uk/reference/examples/data/

jjmontes
  • 24,679
  • 4
  • 39
  • 51