[SalesForce] PDF has no file extension .pdf when generated with visualforce

I am generating a pdf invoice with visualforce, but when it downloads there is no file extension. I have read other questions on SE and tried to simplify the content. Right now the code is simplified to

<apex:page standardController="Invoice__c" renderAs="pdf">

   hello

</apex:page>

and the file extension is still not added to the file.

Best Answer

You can set the name and extension of the PDF explicitly as follows, for example

Apexpages.currentPage().getHeaders().put('content-disposition', 'attachment; filename=AccountReport.pdf');

Unfortunately this is directly not supported in tag in Visualforce.