Control the viewing of pdfs - google-chrome

I have some pdfs that should be viewable but not downloadable. Currently the pdfs are viewed and displayed in different browsers differently through various browser plugins that all permit pdf downloads. Is there a way to restrict these downloads if not in all plugins then just the google chrome pdf viewer specifically. Or is there a simple cross browser solution for viewing pdfs but not allowing them to be downloadable

By the time the PDF gets to the browser plugin, it's already been downloaded.
If you only want one page at a time, you'll need to implement a server-side mechanism to handle that. Like Amazon's "Peek Inside" feature

Related

Chrome PDF Viewer Fit To Page

I have a user that open hundreds of PDFs per week through the PTO’s Electronic Filing System and need to review them in the browser. When Firefox isn’t working with the PTO (I was able to customize Firefox), I have to use Chrome. To manually have to click on every PDF so that I can then go through them page-by-page is not practical. Is there a way to not have to manually fix the page layout every single time I open a pdf. I want to set the default to fit page mode so that I don’t have to do that the hundreds of times I open PDFs in the browser.
Can change this with javascript or PS?
I answered this question here: How to set fit width when embedding pdf in Chrome?
It requires creating an iframe, so it may not be ideal, but my solution provides some reusable code that I use on my websites. HTH!

Which file types can be viewed in browser (inline, without a plugin)

I just want to know which file types (like .png, .pdf, .txt) can be viewed in browser (like Chrome, Firefox). Because sometimes when i click on file link, instead of displaying in browser it download automatically. Why this happens ? Below is my code. Any help will be appreciated.
<script>
function openPDF(url){
var w=window.open(url, '_blank');
w.focus();
}
</script>
<a href="burger1.jpg" target='_blank'>link</a>
<div onclick="openPDF('1.pdf');">PDF 1</div>
It indeed depends on several factors:
the server response Content-Disposition header value inline (open it) vs attachment
(classic download)
the browser configuration (how to behave for various file types)
installed browser plugins
the ability of the browser to open the file
A detailed technical explanation can be found here: https://superuser.com/questions/1277819/why-does-chrome-sometimes-download-a-pdf-instead-of-opening-it
For example Firefox can open most PDF files (but generally not advanced forms, encrypted files ...),
https://support.mozilla.org/en-US/kb/view-pdf-files-firefox
https://support.google.com/chrome/answer/6213030?hl=en
https://helpx.adobe.com/lu_en/acrobat/kb/open-in-acrobat-reader-from-chrome.html
https://www.investintech.com/resources/blog/archives/3684-view-pdf-files-mozilla-firefox.html (about browser PDF reading)
Most advanced PDF features will require the user of Acrobat Reader or a special Acrobat Reader plugin.
There are two aspects to this issue.
There are addons you can add on to the browsers to allow viewing virtually anything in the browser window. In the case of PDF, for instance Firefox can't show those by default, but you can install an addon. Or, there are standalone PDF viewers that also come with such an add-on which you can activate if desired.
And when you've done that, as noticed in the comments, if the resource is marked as download, the browser will download it instead of trying to open it, no matter the file type.
Ditto if it has a http header of Content-Disposition: attachment.
So don't use that.
In normal cases, following files can be viewed in browser.
.PNG
.JPEG
.PDF
.doc
etc ...
and following files will always be download.
.zip
.exe
etc ...
But in special cases, it depends on user browser settings and preference. You can get further details from this link.

How do I get rid of the sidebar and toolbar when embedding a pdf in an html file?

Trying to embed a pdf on my website like so:
<iframe src="filename.pdf" type='application/pdf' frameborder="0"></iframe>
The website is a rails site, and currently I'm only running it on a local server.
The problem is that the pdfs render with a toolbar on top and a sidebar with my adobe creative cloud account information, as seen in the picture below (the actual content of the pdf displays in the white box under the toolbar and to the left of the sidebar)
How can I get the pdf to render alone, without the menu and sidebar?
If you allow the browser to choose how the PDF gets rendered, you're never going to be able to create a consistent experience for your users unless you are in a controlled desktop environment.
If you are looking for a consistent experience, use pdf.js to render the PDF in the browser.
If you are in a controlled environment and all of your users have a browser/viewer combination that will let the browser show PDF using the Adobe Reader plugin (as your screen shot shows) then you can use the "open parameters" at the end of the URL to control what gets shown. See the documentation at the link below.
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf
That said, don't count on that solution to work for very long. Most modern browsers are not allowing the viewer plugins to function anymore and the rest are moving in that direction.
Searching more into stack, try that:
https://stackoverflow.com/a/2105095/7741129
For more detailed informations:
http://blogs.adobe.com/pdfdevjunkie/web_designers_guide
I think it's better use some kind of JS stuff just in case of cross-browser issues, like related into first link. Solutions like https://pdfobject.com/ it's helpful to get the job done. Look:
PDFObject 2.0 detects browser support for inline/embedded PDFs. (In
case you were wondering, your browser supports embedded PDFs. You
lucky dog, you!)
If you're working with dynamic HTML, such as a single-page web app,
you may need to insert PDFs on-the-fly. However, PDF embedding is not
supported by certain browsers. If you insert markup without first
checking for PDF support, you could wind up with missing content or a
broken UI.
The PDFObject utility helps you avoid these situations by detecting
support for PDF embedding in the browser; if embedding is supported,
the PDF is embedded. If embedding is NOT supported by the browser, the
PDF will NOT be embedded.
By default, PDFObject 2.0 inserts a fallback link to the PDF when the
browser does not support inline PDFs. This ensures your users always
have access to your PDF, and is designed to help you write less code.
The fallback link can be customized, or the option can be disabled if
you prefer.
PDFObject 2.0 is npm-ready. Modern web apps use npm to manage packages
and dependencies. PDFObject 2.0 is registered with Node Package
Manager (npm) and can be loaded dynamically.
PDFObject also makes it easy to specify Adobe's proprietary "PDF Open
Parameters". (Be warned these parameters are only supported by Adobe
Reader, most PDF readers will ignore the parameters, including the
built-in PDF readers in Chrome, Internet Explorer, and Safari. Read
more below.)

Controlling the zoom width when a pdf is opened in a browser

I understand browsers open pdf files in different ways and can be controlled in different methods (chrome://plugins, option>applications for Firefox etc.). Is it possible to adjust the resolution at which they are displayed at?
Say I click on a link that opens a pdf file in a new tab. Through HTML5, CSS, Javascript or some other method, is it possible to make it so that the pdf file is displayed at 100% resolution across all browsers?
It depends. There are at least two ways that this could be achieved.
The individual PDFs could have an Open Action that defines how
the PDF should be displayed when opened (in Acrobat this is the
Initial View in the Document Properties dialog). Not all PDF viewing applications will support this though (including the
plugins/extensions for viewing PDF in a browser). This would be the most universal way though as you do not have control over where users will open the PDF.
Determine if the various plugins have support for specifying this is part of opening a PDF. Other questions on Stackoverflow indicate that this is not possible with Google Chrome, see this answer.

Open a PDF in browser 2 page up view

Is there a way to embed a pdf in a page and when it opens, to show two pages at once, side by side?
I want to simulate what happens when you open a pdf in Adobe Acrobat, then check "Two page View" and "Show cover page in Two Page view" under View->Page Display
I don't want to use a pdf reader script in my page; I'm happy if this only covers the set of users using more advanced in browser pdf readers.
Cheers
What you are trying to do involves browsers from multiple vendors and multiple versions of it, there is no concise and succinct answer to your question.
When trying to present a PDF document to a user via the web browser, in a particular fashion, you could use the following Parameters for Opening PDF Files
However, the parameter that you are looking for "Book View", i.e, Two Pages in a single view is not supported as per the official documentation.
Chrome and Acrobat are no longer compatible.
Change in support for Acrobat and Reader plug-ins in modern web browsers
For, other browsers that still support PDF plugins, use the following guidlines to Display PDF in browser
(This is mostly on the user side)