How to make download PDF html code download on computer - html

I'm creating a button which will download an original file in a PDF format. I already have a zoom button if they want to read the PDF via the browser. But I want to offer the possibility to the user to download the file if he prefers, obviously the downloadable file will have a higher quality.
I've tried some basic coding but the problem is that the PDF is opened in the browser. I'm not using any CMS and won't in a future, so the photos are uploaded simply via html code and by placing the picture in the correct file, so no database is present. This is the code I'm using in this moment:
<img class="icons_infobox" src="./_img/prensa/icon_download.png" alt="Download original file" />
This website needs to be cross-browser compatible so I also will ask the answer to be browser friendly.
Thank you very much!

Hello curious people!!!
After gathering and investigating what could be done I've found some answer. I will give as an answer only two options:
100% sure it downloads but not so nice for the user
-Only sure way is converting the downloadable files into .zip. Yes its not too handy/elegant but that is for sure the way the browser will be obliged to download this file. ZIP format files are always downloaded.
Depends of the users browser preferences
-Yes, you cannot be completely sure but its a very close approach. You will need to create a .htaccess file in the folder where you have your PDF for download. You would need to create this file and place it in with the following code:
SetEnvIf Request_URI "\.pdf$" requested_pdf=pdf
Header add Content-Disposition "attachment" env=requested_pdf
I hope this helps somebody. In my web it did work perfectly. It divers between browsers but it works... You just need to know that there will be a porcentage that will see it displayed in the browser and not downloaded.
Greeeeetings,
Dani

Related

Why isn't my HTML page loading completely?

I recently started my first HTML project with the help of Youtube. I'm a beginner and only saw the basics of Javascript in college.
Just finished writing my HTML project and wanted to upload it for free using Google Drive and drv.tw.
The only problem is that certain images and icons do not load (irregularly) enter image description hereand/or the pages on the navigation bar take too long to switch.
My question would be, is it because of the free domain or did I do something wrong in HTML?
When I open the HTML file in Safari everything works fine.
Since I'm new to the community, I don't know exactly what and how much I have to upload to get help. So have mercy on me :'D.
To help troubleshoot, use your browsers "developer" (F12) mode. Look at the Network view to see why the images aren't displayed. For example: It might be "not found", "not authorized", or other reasons.
From your comment, it would appear that at times the page is rendering before the images are available to display or something else is limiting image files from being presented at all.
Once we know why the browser can't display the images, then the cause can be addressed.
Post the .html .js and .css code
Please update your question and show the folder structure. It should look something like:
-site-
|
-js
-css
-images
Copy and paste in the code below the folder structure and list the images and their size.
I am not familiar with google drive's capabilities.
It is important to use a web host. There are plenty of free or low cost sites available, so I won't go into it.

The page is not reading my image and I don't know why

I finished my project, but although the extension Live Server is showing everything right, the images I added. When I open the page from the documents or from GitHub it is not reading SOME images. Does anyone recognize this error??
Ps: I'm just using HTML and CSS, making a portfolio.
I also faced the prob, what you need to do is just upload the folder again on Github using (Check wheter you are uploading the correct folder and the files are linked correctly.). And than again download it. It may solve the problem.

is there a place online to upload a json file and export it in html?

I have bookmarks downloaded from firefox and they are a json file.
I'm searching for a site where I can upload the json file and then download it in html format.
Does such a site exist?
THANK YOU for your kind assistance.
(Every time I do a search for this question, your site comes up.)
I don't know of a site that will do this online, but I do know of a few other ways:
You could restore them back into a Firefox profile and then export them as HTML from there, like this:
You could download and run a program like https://github.com/andreax79/json2html-bookmarks to convert them locally
You could use JavaScript to convert them in-browser, though not with an actual site, like this: Quick and dirty way to parse a mozilla firefox json file
If you need to display JSON, try with the firefox extension named jsonview.
Check out CodeBeautify, just paste and hit the Beautify button https://codebeautify.org/json-to-html-converter
There’s a lot of plugins and add ons for almost every browser out there; Firefox and especially chrome have great ones as others have mentioned, it’s worth checking out.
You are making it harder than it is. There is no JASON to HTML conversion required. Go to C:\Users\Username\AppData\Local\Google\Chrome\User Data\Default and find bookmark.file. Save it to your desktop. Uninstall the browser but also check the box that asks whether you want to keep history, etc.
Reinstall the browser, then add the bookmark.file to C:\Users\Username\AppData\Local\Google\Chrome\User Data\Default
It will overwrite the file and you have your bookmarks back. It takes about 10 minutes. No coding. No JASON to HTML conversion. Nothing.

Instruct browser to make user select location for downloaded file?

Some browsers has the option to automatically save downloaded files to a folder, without prompting the user where to save the file. This has posed a problem for us where the user automatically saves the file in "Downloads" instead of selecting a proper location.
Is there any HTML-attribute, HTTP-header or JavaScript solution to instruct browsers to prompt for save location for downloaded files even though they are configured otherwise?
Note: I am well aware that this is probably not possible, but wanted to see if someone hopefully can prove me wrong.
Related issues:
How to make browser download link target instead of navigate: Force to open "Save As..." popup open at text link click for pdf in HTML
No. It's a browser preference. If the user prefers not to be bothered by their browser for download locations, then that's their prerogative. They'll deal with the file location after it has been downloaded. A server cannot influence that behaviour.

Embed PDF on a webpage and prevent download

Is there a way to embed a PDF document on a webpage and at the same time disabling download? If possible I would prefer an html5/css3 solution. If no other way is possible I'd go with something else.
just add #toolbar=0 to the url of the pdf
Yes. Yes there is:
<div id="pdf">
<object width="100%" height="650" type="application/pdf" data="[ImageURLHere]#zoom=85&scrollbar=0&toolbar=0&navpanes=0" id="pdf_content" style="pointer-events: none;">
<p>Insert your error message here, if the PDF cannot be displayed.</p>
</object>
</div>
The pointer-events: none styling will also prevent users from right-clicking the PDF and downloading.
Actually, it is possible, you can adjust in your Google Drive option "Prevent viewers from downloading"
Then set PDF file public, so everyone can view PDF in Viewer, but none can download it.
I hope, that this will help for some.
Short answer is, it can't be done. The only way to view a PDF document without any kind of conversion is via the adobe PDF plugin, and that invariably allows the document to be saved. On top of that, it's trivial to use various tools to get the url of the PDF and download it from there.
If you want to avoid sending the actual PDF document, you could create a server-side script that converts the PDF document to a series of PNG or JPG images behind the scenes. You can do this with ghostscript for example.
But then, the actual content of the document still reaches the user, only in a different format. If this is not satisfactory for you, there are various techniques you can use to prevent most users from saving the images, but these are easily circumvented by a sufficiently technically savvy user.
You can use SlideShare, you can set a read password, prevent users from downloading in the settings, and even create a secret link so only users with it can open it. I am sure there are ways to circumvent this, but at least it's not immediate.
You can download the PDF.js and modify these 2 files: viewer.html and viewer.js, remove/modify the corresponding buttons/actions in order to disable downloading/printing, and you can furtherly disable right click menu items.
2017 Note: this feature has moved locations and the implementation has changed since it was originally answered.
Google Viewer offers a solution.
Use the iframe it generates for you.