I am using nodejs server to serve static files. When the pdf file is served, the browser displays the title as URL of the pdf path.
How can I set this to a custom title say "Sample"
I have tried following things but no luck :
- res.setHeader('Content-Disposition', 'inline;filename="sample.pdf"');
- Setting meta tag of pdf file as "sample"
Any help will be much appreciated.
Best How To :
If you're using a static file server, then yes you are serving it as a download. Modern browsers often contain a built-in PDF viewing plugin, so instead of asking the user where to save the file, the browser will instead just display the PDF right in a browser tab. It still downloaded it, it just saved it to some temporary cache on your machine in that case.
Now, if you were to embed the PDF file in an HTML page with some kind of PDF viewer then you could control the page title with a simple
<title>some title</title> tag or calling
Here's an example of an embeddable PDF viewer. http://pdfobject.com/