• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

PDF save file type in browser

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My application has a page of downloading a server side generated PDF file.  In IE it works in a way that in the "save as", the file type auto shows "Adobe Reader", but in Chrome it only shows "All files".
 
Master Rancher
Posts: 5112
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the server set the response header's Content-type?
 
Marshal
Posts: 4699
588
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:Does the server set the response header's Content-type?


In addition, the response may also need to have a Content-Disposition header:
    Content-Disposition: attachment; filename="MyFileName.pdf"
 
Norm Radder
Master Rancher
Posts: 5112
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you always want the file to be downloaded
or do you want to be able to view it in the browser?
 
Saloon Keeper
Posts: 28486
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's important to remember that web browsers don't receive "files", they receive data streams. The data stream's "type" should be marked via a Content-Type header.

Content-type refers to a MIME value. MIME, incidentally, stands for Multimedia Internet Mail Extensions, since it was first designed for email with non-text content, then adapted for web use.

When a web client (browser) receives a data stream, it looks up the Content-Type MIME type. There's typically a file or database somewhere it references, either client-specific or sometimes system-wide.

The MIME type lookup typically will return what filename extension(s) that type is associated with. For example, in the global MIME mapping (/etc/mime.types) file on my machine, the type application/gzip assiciates with "gz" and "gzip" file extensions.

In-browser MIME mapping may also specify the default disposition for a data stream - that is, "display in browser" or "save as file".

So the file save options dialog's selection of default file types for a given Content-Type depends on the browser and the browser's preferences possibly augmented by sysytem preferences.
 
Ranch Hand
Posts: 82
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Install an Extension in chrome browser, go to “Chrome Web Store” -> search for “PDF Mage” in the search bar -> click on “Add to Chrome” -> after installation is complete, go to any webpage and click of “PDF Mage” Icon and the web page will be converted to PDF.
Install “Nitro PDF Reader”. Press “CTRL+P” -> look for heading “Destination” -> click on dropdown -> Select “Nitro PDF Creator” -> Click “Print” (Popup Window will appear) -> Select destination Folder & name for the file & finally click on “Save”
Press “CTRL+P” -> look for heading “Destination” -> click on dropdown -> Select “Save as PDF” -> Click “Save” (Popup Window will appear) -> Select destination Folder & name for the file & finally click on “Save”
Press “CTRL+P” -> look for heading “Destination” -> click on dropdown -> Select “Save to Google Drive (will be saved as PDF in Google Drive)” -> Click “Save” (will automatically be saved as pdf in Google Drive if Google account is be Signed In)
Hope this will be helpful.

I hope this will help you.
 
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic