1

Here is our Visualforce Page Attributes In this example we are trying to name the PDF "Hello"

<apex:page title="PDFPage" renderAs="pdf" standardStylesheets="false" standardcontroller="custom_object__c" docType="html-5.0" showHeader="false" sidebar="false" recordSetVar="customObjVar" contentType="application/pdf#hello" >

How do we name a Visualforce PDF without Apex?

Normally in Apex this is what we do:

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

So how do we set the content-disposition parameter using visualforce?

UPDATE When we change the renderas="html", it tries to open the document in Adobe (default pdf application) as expected, and with the correct filename, but of course Adobe errors because the content is not pdf, so application/pdf#filename works but not when renderas="pdf" Weird!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.