Downloading HTML files without opening a browser - javascript

I have a URL which I don't want to open up in a browser. The servlet which my URL points to is able to download the JPEG image of the rendered HTML document using html2canvas library based on specific params.
How can I download the HTML as JPEG even without rendering the HTML on the client side. Is that possible?

Related

Prevent PDF Download in PHP

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?

Chrome PDF Viewer embedded download button not working

Clicking the Chrome PDF Viewer download button directly downloading the server-side file.
I'm using ColdFusion server to generate the pdf file and view it in a separate tab with inline. PDF was correctly viewing in a tab but when clicking the download icon I can able to download that PDF file, it was downloading my .cfm file.
Try swapping 'inline' with 'attachment', in your Content-Disposition header.
Basically, inline will try, always varying by borwser, to open the file inside the browser. In any case what you're trying to do you should definitely use attachment. This will directly go to the user and force a download.

Download pdf in javascript and embed it

I have a webservice that will respond with a pdf on certain post requests.
I need to be able, in javascript, to download this pdf and embed it on my page. How would I do that?
I don't have a direct URL only the data passed back by the AJAX
You can try out PDF.js. However, it doesn't support all the browser.
An alternative with IE support is thatyou could just insert a iFrame, and change the src to the location of the PDF.

Open PDF from HTML5 Storage

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).

Cache external embed pdf with javascript or html

I have the following external pdf embedded as shown below. The pdf displays fine, but how do I cache the pdf so that the page doesn't redownload the pdf each time I visit the page? Should I use an object tag instead?
<embed src="http://samplepdf.com/sample.pdf#toolbar=0&navpanes=0&scrollbar=0" width="500" height="375">
From my understanding, you have a pdf on your server that you would like to cache onto the client side so that the pdf is not redownloaded each time the user refreshes the page.
By sending the proper headers, you can enforce cache rules (or at least try to enforce them as any browser can overrule your rules).
Php or in your case, Django, can send the appropriate headers to tell the browser to cache this pdf. My recommendation would be that you link that you provide in the embed tag links to a script instead of the pdf diriectly. This django script would sent out 2 sets of headers. One tells the browser to cache this content and other tells the browser it is sending a PDF file. This ensures that the pdf gets cached. When you load a webpage, the typical headers' scope by not encompass all external files/pdfs. As each is a separate request.
The method that I prescribed adds extra work than simply embedding the pdf but it should get the job done.

Categories