• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

PDF save file type in browser

 
Ranch Hand
Posts: 148
  • 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: 4250
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: 3457
493
Android 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: 4250
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: 23409
159
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.
 
You can thank my dental hygienist for my untimely aliveness. So tiny:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic