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:
The user visites my site and downloads a bunch of pdf's into a storage
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?
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/
Create links with PDF type and base64 encoded data (representing the PDF binary)
PDF name
The base64 encoded content can be stored in HTML5 storage.
Warning: does not work for IE (excuses for security reasons).
Related
I am writing a Chrome extension that manipulates PDF files and am looking to get all the text of a PDF file that's currently open in Chrome's PDF viewer.
I learned from
How can I get selected text in pdf in Javascript?
how to get selected text, but I couldn't find in the API a function that extracts the entire text (or better yet the PDF itself, and then send it to a server). Is it possible?
I am aware of the solution of sending the URL and downloading it on the server side, but sometimes it is problematic (e.g. PDFs from password-protected websites).
Thanks.
I have tried looking in the API, https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/resources/pdf/pdf_scripting_api.ts
I have also tried "downloading" the PDF on client side and sending it as Blob to a server, but it's a problematic solution (sometimes blocked for example, requires extra permission).
Is there any way to prevent PDF download and printing option from browser ?
I am using PHP codeigniter for uploading the PDF file from admin side. I want to restrict the download access, inspect access, page source access from user side. Users only need to read the PDF.
So is there any way to do this using PHP or Javascript?
Users can take screenshots, which is not a problem. I only wan't to prevent the pdf url and download access in all aspects.
Do we have to convert PDF to any other format for this?
Background:
I am trying to migrate a traditional web application into Windows 8 Store App with the least efforts, the basic idea is run the web application into the web view.
Problem:
1. The web app will produce a PDF file and display it directly in the browser using PDF binary (Base64), is it possible to listen the action, and intercept it, and so that i can get the PDF content?
2. If it's impossible to intercept the action (open PDF in a popup browser tab), is it possible to get the PDF content via Javascript in a existent rendered browser page (with PDF rendered)?
3. I previously thought that it's PDF viewer plugin helps browser to open PDF, but sounds not, as i checked my IE setting, there's no PDF reader plugin enabled, then how it can open PDF?
4. In the existing web application, the PDF page is invoked via "window.open(url,...), while the URL is the link to response PDF binary, the corresponding server side implementation of this link is very sample, it just "write" the PDF binary into the "response" object, and set the "content type" with "application/pdf", that's it.
On click of a button, without doing a round trip to the server, can we save a HTML5 page on clients machine as PDF.
Check out PDF.js. This lib can create pdf in the browser (or serverside on node.js).
Using chrome you can print the page to a pdf file.
You need something like this, maybe server-side you can start a browser and print the content to a pdf file and send this to the client.
Disclaimer: i work for ByteScout
If you have simple HTML formatting and want to generate PDF on client side and if you have non-commercial project, check BytescoutPDF.js - it supports simple HTML formatting for text (font name, size, color) plus simple drawings and images, should be enough for simple reports
Is there a cross-platform way to do these actions? Or only open files, the user download the files. I want to make a mmo side-scrolling game, and it needs to save maps, sprites and musics.
It's not possible to access the local filesystem at the client's side. If your data is text (image -> text through base64 data uri's), the DOM Storage may be interesting for you. The files must be base64-encoded at the server's side, though.
References:
https://developer.mozilla.org/en/data_URIs
https://developer.mozilla.org/en/DOM/Storage
JavaScript has no I\O capabilities by itself.
If you want to reduce the traffic use the model in Travian:
the user can save all of the resource files needed to his PC, device etc;
the user submits to the server the path, where the resource files are saved;
the game generates custom css with localpath (the path to the files on his machine).
This will reduce the traffic enormously.