Failed to load PDF document in Chrome - google-chrome

I have a PDF file stored on my server. I am unable to access the file using Google Chrome (or Ubuntu Chromium) via URL "sitename/pdfName.pdf"; while I am able to access the same PDF in Internet Explorer or FireFox without a problem.
Chrome is giving this error: "Failed to load PDF document"
Find attaching the error in this link Error Image.

We had object:none in our security policy inside web.config, that was causing chrome to refuse to open it, and pressing f12 in chrome and then click "console" shows the error message.
Changing web.config security policy to object:self fixed the problem
In our case we could open PDFs in firefox and IE but not in Chrome, so Chrome has a stricter implementation of the security policies.
The below is a suggested edit which I have not tested:
You may also find that Chrome has a problem with the header of the name: Content-Type value: charset=utf-8. Removing it may fix it.
Also, as you are testing this, make sure that cache is not interfering with the response by keep on changing the request URL to something new sitename/pdfName.pdf?val=1 and then with the next test, ?val=2 and so on...

When we encountered this problem, the only difference between PDF files that did and did not work was in the fist line of the PDF document itself.
Here's the difference between the old PDF that caused the error and the fixed version as seen in a binary-enabled text-editor (in this case vim -b):
Original PDF file:
%PDF-1.6^M%<e2><e3><cf><d3>^M
Fixed PDF file:
%PDF-1.6^M
%<e2><e3><cf><d3>^M
So the problem was solved at the source, no need to burden the victims with installing extra software or reinstalling chrome.
I don't know if this is a problem with the PDF generator, or with the chrome plugin.
According to the PDF specification the first line of a PDF document has to contain the PDF version, but it's not completely clear to me if the ^M is a valid line separator.

This might be due to Chrome’s built-in PDF Viewer not being able to open Firmex’s protected PDF document.
Try:
Opening Google Chrome (obviously)
In the top right, click More Untitled.png, then Settings.
At the bottom, click Show Advanced Settings.
Under Privacy, click Content Settings
Under PDF Documents, check the box next to "Open PDF files in the default PDF viewer application."
Once you have made the change, PDF files should open in Adobe Reader or Adobe Acrobat, rather than in Google Chrome.
Although it may not be ideal, it's a good alternative for now.

I had the same problem. In IIS I had to add this web.config file to my PDF folder to get it to work
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="Content-Type" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
You may also find that Chrome (on Ubuntu 19.04) has a problem with the header of the name: Content-Type value: charset=utf-8.

Related

Trying to install Outlook as a PWA: wrong manifest fiile link on Chrome

I'm trying to install Outlook as a PWA (https://outlook.office.com) but the button to install it is not displayed. It is possible on Egde browser, and I was able to install it, but it's annoying for me since my default browser is Chrome.
When I check what is going wrong in the Chrome Console, I can see it tries to download the manifest file from here https://outlook.office.com/mail/manifests/pwa.json?culture=fr
Notice the culture parameter which is added. Going on that link return an invalid XML:
<?xml version="1.0" encoding="utf-8"?><Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.
RequestId:61dcf34d-901e-003c-1e84-fae306000000
Time:2022-11-17T12:57:14.6332369Z</Message></Error>
Removing the parameter, and going here https://outlook.office.com/mail/manifests/pwa.json displays the XML of the manifest properly
I tried to remove all my cookies/history, it did not change anything.
Does anyone also encounter this kind of problem and fixed it?
Thanks for your help
If you open up outlooks web setting and then go through to all settings set the language to English (United States) and then restart your Web app https://support.google.com/chromebook/thread/175421592?hl=en&msgid=180181854

Embedded PDF Issue in Edge Browser

When using the Microsoft Edge browser, by default when you open a PDF it will open the PDF in a new tab using the built-in PDF viewer. To avoid this, you can adjust the browser's settings: Toggle on the "Always open PDF files externally" option. This works great. However, it presents a separate issue. Our internal applications use embedded PDFs in iframes. When the external toggle is set to on, these PDFs will not show in the iframes. This doesn't happen in Chrome. Has anyone else experienced this and know a work around?
I've tried removing the type="application/pdf" from the iframe tag to no avail. I can't find anything else online.
It looks like an expected result because you have enabled the option Always open PDF files externally.
So MS Edge browser is giving you an option to download the PDF file and open it using the desired app.
You said this doesn't happen in Chrome browser.
If you enabled the Download PDF files instead of automatically opening them in Chrome option then you will notice the same result in the Chrome browser.
Output in the Chrome browser:
If you click on the Open button then it will download the PDF file.
I did not get any solution or a workaround for this issue.
If you think that there should be an option to load the file in an iframe if Always open PDF files externally option is enabled then I suggest you click on the Send Feedback button in the MS Edge browser and try to provide your feedback about it to the Microsoft.
I posted feedback suggesting that an exclusion/inclusion list be in included but the simplest way would be to treat the frame as part of the session. But this is not Microsoft it is the Chrome projects issue.

SAML URL works in IE and Firefox, but not in Chrome of Safari

I have a URL here:
www.soph.uab.edu/interntrackv3/saml_login
If you go to that URL with IE or Firefox, you will be redirected to my IdP for login. If you go that site with Chrome or Safari, you will download a file that is an HTML file if you open it.
I need Chrome and Safari to redirect like IE and Firefox do. This was working on IIS7.0 PHP 5.6.4. I am now on IIS10 and PHP 7.3. I'm assuming this is a server setting and some issue with the way Chrome and Safari handle the type of file being generated (this file is not stored anywhere on my server that I can find - it is generated at request time).
Anyone know what setting could have changed that would cause this change in behavior? Thanks!
I’ve got it fixed. When the site was redirected from HTTP to HTTPS it was changing the Header of the file from text/html to document under Google Chrome. I added:
<httpProtocol>
<customHeaders>
<add name="X-Content-Type-Options" value="nosniff" />
</customHeaders>
</httpProtocol>
To my web.config file and it is now working correctly.

Why Chrome doesn't update Typescript source files on change?

I'm working on a TypeScript (0.9.1) project using Visual Studio 2012 with the latest Web Essentials as the IDE, and i debug using Chrome Developer tools.
Recently, and most probably after Chrome update (cur. Version 29.0.1547.66 m), typeScript files don't get updated after i edit them, and on the other hand the corresponding compiled js files are updated, but it seems that somehow the functionality still depends on the non-updated version of the sources.
Solutions tried and failed:
Rebuild the full solution.
Hard refreshing (Shift + F5) the local host site on chrome
Deleting Source map files and generate them again.
After some trials it looks like even a request to download the ts source files yields the non-updated version (http://localhost:1198/xxx.ts e.g)
It seems that the problem gets partially fixed after full restart (windows 8 if it matters), the source files are updated in chrome, but once i change it again, the same problem appears.
Another solution was using incognito, as it seems that it's a caching problem.
My question:
Is caching typeScript files that way is caused by a problem in the configurations of the project (even it was working before), or this is a bug in the new version of Chrome ?
To I'm experiencing same problem. I solved this problem with chreome debug tools disable cache checked.
My second problem, i wrote a lot of class into a same file.
i splice every class to seperate file.
I solved this by removing the cached files manually. This can be done through Chrome's settings:
Click on Customize and control Google Chrome - the burger menu icon in the top right corner of the browser window.
Select Settings near the bottom of the menu.
Scroll down and click on the Show advanced settings... link.
Click on the Clear browing data... button.
Check Cached images and files. The other checkboxes can be left unchecked.
Click on the Clear browing data button.
The 'Disable cache' checkbox in the network tab didn't work for me, nor did a Ctrl+F5.
If you are serving from IIS, We have manually disabled cache in our web.config file :
<system.webServer>
<httpProtocol>
<!--TODO: Remove this block for production (//TODO: Remove this block for production) -->
<customHeaders>
<!--DISABLE CACHE-->
<add name="Cache-Control" value="no-cache, no-store, must-revalidate" />
<add name="Pragma" value="no-cache" />
<add name="Expires" value="0" />
</customHeaders>
</httpProtocol>
</system.webServer>
I don't know why it doesn't work normally. But even when you turn off caching it still doesn't work. What does work as a manual work around. If chrome dev tools is open then you can right click the refresh icon and do a hard reload (I do 'Empty Cache and Hard Reload') and it works.
I solved this like Jan Aagaard .
Customize and control Google Chrome > Settings > Show advanced settings... > Clear browing data... > Check in 'Cached images and files' > Clear browing data.
If anyone have the same issue on Visual Studio 2015 after installing ASP.Net 5 RC1. Check if the Browser Link Dashboard displays "No current connections" when running or debugging a DNX project a repair of the update will correct the issue:
Close Visual Studio
Open Control Panel > Programs and Features
Right click on "Microsoft ASP.NET 5 RC1 Update 1"
Click "change"
In the ASP.NET 5 RC1 Update 1 Installer, click "Repair"
In our case we had the wrong workspace directory set on the Sources - Page tab.
i.e. it was pointing to project-master but we were actually debugging in project-branch
So the solution was simply to set the correct workspace directory.

View local html file with .asp extension in browser

Hi I have crawled a website for offline view, but many pages are downloaded and saved as .asp and there are links that point to these pages. But when I open these html page that has .asp extension in Chrome browser, the chrome will download the page instead of rendering the page. Is there a way to set the chrome to render the page instead of downloading it ?
Thanks
Chromium uses the system mime-type for the local files. On Linux you can change it in the xdg-open configuration:
$ mkdir -p ~/.local/share/mime/packages
$ cd ~/.local/share/mime/packages
$ touch application-x-asp.xml
Then edit the ~/.local/share/mime/packages/application-x-asp.xml:
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="text/html">
<comment>Active Server Page</comment>
<icon name="text-html"/>
<glob-deleteall/>
<glob pattern="*.asp"/>
</mime-type>
</mime-info>
to set up the mime-type to text/html. On te end you have to logout/-in again, or just run:
$ update-desktop-database ~/.local/share/applications
$ update-mime-database ~/.local/share/mime
When your browser opens a file it uses the MIME type to decide which action it should take, typically download or open in the bowser.
So, for example, it encounters a zip file it will open the file save dialogue box and allow you to save the file.
And, if for example, you request a .asp from your browser which is served from a web server the browser will use the MIME type to decide which action to take, which will be to display in the browser.
The MIME type will be sent within the http headers and this would not be sent to the browser when you open your off-line .asp pages.
So if you could change the MIME type to "text/html" for .asp it should open it in the browser.
Unfortunately, there does not seem to be an option for changing MIME type / actions in Chrome.
You can change these setting in Firefox within Tools > Options > Content > FileTypes > Manage..
There is a way to open local, .asp files as HTML in Firefox.
Find your Firefox profile folder. On Windows 7, I found it here:
C:\Users\user\AppData\Roaming\Mozilla\Firefox\Profiles\738xdie.default\mimeTypes.rdf
Then add these lines to mimeTypes.rdf
<RDF:Description RDF:about="urn:mimetype:text/html"
NC:fileExtensions="asp"
NC:description="ASP Pages"
NC:value="text/html"
NC:editable="true">
</RDF:Description>
Restart browser. Your local file will now render as HTML.
There may be a similar technique with Chrome.
I suppose you want to view downloaded pages directly, that is not via some local web-server. Then I'd suggest to change (or append) file extensions during download according to their reported content-types from response headers. Of course, this will require to adjust all links to changed filenames inside other files. The other approach could be to store content-type of each page in a meta-base, and using a local web-server to serve the files according to their actual types from the base, not file extensions.
I have two solutions for you. the first one is to open those files with firefox.. and that's it..
if you insist to open them with chrome. you have to change all files extension to html instead of asp. use some programs for renaming..
but the links will be broken between pages..
so you have to find the js file that all pages use add this code in it to fix the links
document.body.addEventListener('click',function(e){
if(e.target.nodeName=='A'){
e.preventDefault()
href=e.target.href.split('/')
href[href.length-1]=href[href.length-1].replace('.asp','.html')
href=href.join('/')
parent.location=href
}
})
})