Changing the name of the browser tab in the file name when send_file pdf

In my project, I use Carrierwave to download files like doc and pdf . In case I want to download pdf my controller,

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

And it works great, displays the pdf file in the browser, and the URL I got is / documents / file_name , which is good too. But I want to set the header header or url header, so the browser tab displays the file_name instead of myapp.com/documents/file_name

Is there an easy way to do this?

+5
source share
1 answer

Unfortunately, this is not possible as you describe.

The name of the tab is taken from the metadata of PDF documents, in particular the Title attribute.

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

+2
source

All Articles