• 0

Prevent chrome from opening PDF


Question

I know the first thing you are going to think is disable the PDF add-on in chrome... since we are the site providers, that isn't an option, we are not the client....

the problem right now is chrome is not rendering our PDF's correctly, actually it's not rending them at all... it's just showing black pages... every other PDF reader out there renders them correctly... (Something with the software that generates the PDF's, because most pdf's do render correctly in chrome, just not this packages (ahem SSRS)

I need a way to prevent chrome from rendering the PDF when a user clicks a link on our site.

There is one way of doing this by changing the MIME type reported by the web server for the files... normally it's reported as application/pdf if you change it to application/octet-stream chrome no longer auto opens it as a chrome rendered file... but it now downloads it and has it on the download bar... when a user clicks that it of course opens in chrome's rendering engine....... only when you click the drop down to select open in acrobat or system reader does it open in the right one...

are there ANY flags or anything a web dev can set outside the mime type (which we already did) that will make chrome just open a PDF in the native reader directly on a link click?

Link to comment
Share on other sites

17 answers to this question

Recommended Posts

  • 0

I wonder if you could use something out of Exchange's generated HTML that forces conversion/web view of PDF in browser (which is NOT Chrome's PDF view).

Link to comment
Share on other sites

  • 0

I'm going to start concepts for my main company's website. Ones Muse make good performing larger sites? My first site here is fairly simple but it seems to perform well. I really like the WYSIWYG design because of my lack of coding knowledge.

Link to comment
Share on other sites

  • 0

I wonder if you could use something out of Exchange's generated HTML that forces conversion/web view of PDF in browser (which is NOT Chrome's PDF view).

well we've looked at pdf.js to do our own rendering, but clients want to download the files directly to keep them, problem is they aren't the brightest and even with forced download via meta type change to application/octet-stream they still just click the button on the chrome download bar and open it in chrome defeating the purpose and opens blank *grrr*

Link to comment
Share on other sites

  • 0

I'm going to start concepts for my main company's website. Ones Muse make good performing larger sites? My first site here is fairly simple but it seems to perform well. I really like the WYSIWYG design because of my lack of coding knowledge.


Wrong thread? Lol

well we've looked at pdf.js to do our own rendering, but clients want to download the files directly to keep them, problem is they aren't the brightest and even with forced download via meta type change to application/octet-stream they still just click the button on the chrome download bar and open it in chrome defeating the purpose and opens blank *grrr*

I don't think there's an option that fixes laziness and ignorance built into Chrome. :woot:

Link to comment
Share on other sites

  • 0

well we've looked at pdf.js to do our own rendering, but clients want to download the files directly to keep them, problem is they aren't the brightest and even with forced download via meta type change to application/octet-stream they still just click the button on the chrome download bar and open it in chrome defeating the purpose and opens blank *grrr*


Can you tell me who the client is so I can call them and ridicule them for being dimwitted ?  C'mon - it'll be fun !

Link to comment
Share on other sites

  • 0

Can you tell me who the client is so I can call them and ridicule them for being dimwitted ?  C'mon - it'll be fun !

It'd be a list of about a thousand of them....... it's your average older person working in an HR department that can not understand simple directions....

Link to comment
Share on other sites

  • 0

I don't think there's an option that fixes laziness and ignorance built into Chrome. :woot:

Yeah, but when the people three levels above you say "find a way to fix this" you go on a race chasing your tail trying to find a fix..... I've done about everything I can do except ban chrome users :laugh: remember when we use to do that to IE users? gawd now it's chrome.....

Link to comment
Share on other sites

  • 0

Wrong thread? Lol

 

I don't think there's an option that fixes laziness and ignorance built into Chrome. :woot:

Yup lol

Link to comment
Share on other sites

  • 0

I know the first thing you are going to think is disable the PDF add-on in chrome... since we are the site providers, that isn't an option, we are not the client....

the problem right now is chrome is not rendering our PDF's correctly, actually it's not rending them at all... it's just showing black pages... every other PDF reader out there renders them correctly... (Something with the software that generates the PDF's, because most pdf's do render correctly in chrome, just not this packages (ahem SSRS)

I need a way to prevent chrome from rendering the PDF when a user clicks a link on our site.

There is one way of doing this by changing the MIME type reported by the web server for the files... normally it's reported as application/pdf if you change it to application/octet-stream chrome no longer auto opens it as a chrome rendered file... but it now downloads it and has it on the download bar... when a user clicks that it of course opens in chrome's rendering engine....... only when you click the drop down to select open in acrobat or system reader does it open in the right one...

are there ANY flags or anything a web dev can set outside the mime type (which we already did) that will make chrome just open a PDF in the native reader directly on a link click?

 

There is a way to force any file to be downloaded instead of viewed but then they will depend on the file association that Chrome has (since it keeps its own associations, started to hate chrome for this).  If they select open in Acrobat always then it will download and open properly.  However this still depends on the user.  Chrome has locked down any chance of using a form entry pdf or saving one.  This is all for security you see.

 

https://developers.google.com/web/updates/2011/08/Downloading-resources-in-HTML5-a-download

Link to comment
Share on other sites

  • 0

Yeah, but when the people three levels above you say "find a way to fix this" you go on a race chasing your tail trying to find a fix..... I've done about everything I can do except ban chrome users :laugh: remember when we use to do that to IE users? gawd now it's chrome.....

 

Oh how I know that feeling all too well...it's like me trying to find a Sync client that does network share sync as well on Windows, Linux, OSX, Android, iOS, and Windows Phone. Tell people it's impossible, get told to find a way, okay dokey! :rofl:

Link to comment
Share on other sites

  • 0

Besides Content-Type you can try Content-Disposition: attachment; filename=magic.pdf in the header ;)

Link to comment
Share on other sites

  • 0

Besides Content-Type you can try Content-Disposition: attachment; filename=magic.pdf in the header ;)

yep, that's another way we've tried, be it the preferred way

Link to comment
Share on other sites

  • 0

Perhaps the google solution will work best for you, as long as it's available online, you can have google iframe the PDF.

iframe(src="https://docs.google.com/gview?url=URL_TO_PDF_FILE&embedded=true", width="100%", height="720", frameborder="0")

I use this for invoices and it works out just fine for my clients so far, tested in Chrome, Firefox, Edge, Safari and IE (10+) but again sometimes it may be hit miss. The only thing required is that the PDF be accessible online, if you generate them on the spot (like we do) then you'd be able to just have variables that set up parameters obviously.

Syntax is Jade but since it's only the one line that's needed I assume - and hope - you'll be able to convert it to the HTML you're after :rofl:

Link to comment
Share on other sites

  • 0

Perhaps the google solution will work best for you, as long as it's available online, you can have google iframe the PDF.

iframe(src="http://docs.google.com/gview?url=URL_TO_PDF_FILE&embedded=true", width="100%", height="720", frameborder="0")

I use this for invoices and it works out just fine for my clients so far, tested in Chrome, Firefox, Edge, Safari and IE (10+) but again sometimes it may be hit miss. The only thing required is that the PDF be accessible online, if you generate them on the spot (like we do) then you'd be able to just have variables that set up parameters obviously.

Syntax is Jade but since it's only the one line that's needed I assume - and hope - you'll be able to convert it to the HTML you're after :rofl:

by law, the data we are sending out is not allowed to go to a 3rd party like Google... so to have them render it or in any way "intercept" the data is a huge risk for us legally... that's why we always have to make sure it's downloaded to the client directly... now once it is in their hands it's out of our compliance requirements

Link to comment
Share on other sites

  • 0

by law, the data we are sending out is not allowed to go to a 3rd party like Google... so to have them render it or in any way "intercept" the data is a huge risk for us legally... that's why we always have to make sure it's downloaded to the client directly... now once it is in their hands it's out of our compliance requirements

Any other contraints? Because that's kind of a key piece of information when it comes to trying to help someone out, knowing what must be avoided. I can run it past my developers and maybe they'll be able to offer some insight as well, but knowing what can and cannot be done is sort of a big detail.

Link to comment
Share on other sites

  • 0

Also do you have any sort of debugging as to why it isn't rendering the PDF's correctly in chrome? It may be a bug if it's loading fine in other browsers, is it possible to generate some blank/dummy PDF for me so I can run some tests through my various apps and see if anything goes wrong? I want to help out, but I'm also genuinely interested since I'd like to avoid an issue like that myself.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.