Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change browser tab title to file name when send_file pdf

In my project I'm using Carrierwave to upload files like doc, and pdf. In case I want to download a pdf my controller do

send_file @document, :disposition => 'inline', :type => 'application/pdf'

And this works fine, displays the pdf file in browser and the url I get is /documents/file_name and it's fine too. But I want to set the "headers title" or "url title" so in the browser's tab shows the file_name instead myapp.com/documents/file_name

Is there a simple way to do that?

like image 597
Adrián E. Avatar asked Jul 28 '15 17:07

Adrián E.


1 Answers

Unfortunately it is not possible as you describe.

The tab title is taken from the PDF documents metadata, specifically the Title attribute.

If you usually generate your document with Prawn you can do: Prawn::Document.generate(my_filename, info: {Title: my_title})

like image 104
Weston Ganger Avatar answered Oct 06 '22 16:10

Weston Ganger