How can I specify a file name for a Visualforce generated PDF

You would need to set the Content-Disposition header.

In constructor of the Visualforce controller:

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

If you want to make the file name dynamic you will need to refer to several RFCs on how to correctly encode the filename. E.g. if it contains spaces it will need to be quoted. If there are non-ASCII characters or it is longer than 78 characters it needs to be Hex encoded (RFC 2184).


This feature is not yet enabled on the <apex:page/> tag in Visualforce, however, you can set the filename in the <messaging:attachment/> tag in Visualforce email templates.