You need to sign in to do that
Don't have an account?
Sravan R Pinninti
How to customize the name of the PDF while Saving?
Hi,
I have a VF page on which I have a button named "Print". On click of print, the user will be redirected a page which is rendered as PDF. Both these pages use same controller.
Based on a Boolean value i want the name of the PDF to be changed when user tries to Save the file. RIght now, the file name defualts to the name of the page. I have used Apexpages.currentPage().getHeaders().put('content-disposition', 'attachment; filename=AccountReport.pdf' in the constructor and I also tried using this inside a method but both did not satisfy my requirement completely. When I use the above code in constructor, the PDF is downloading even before the page is loaded and if I use the code inside a method the PDF is downloaded directly.
I do not want the PDF to be downloaded. I just want the name to be dynamic when user tries to Save the PDF? Am I missing something here.
Thank You in advance for your help!!
Regards,
Sravan.
I have a VF page on which I have a button named "Print". On click of print, the user will be redirected a page which is rendered as PDF. Both these pages use same controller.
Based on a Boolean value i want the name of the PDF to be changed when user tries to Save the file. RIght now, the file name defualts to the name of the page. I have used Apexpages.currentPage().getHeaders().put('content-disposition', 'attachment; filename=AccountReport.pdf' in the constructor and I also tried using this inside a method but both did not satisfy my requirement completely. When I use the above code in constructor, the PDF is downloading even before the page is loaded and if I use the code inside a method the PDF is downloaded directly.
I do not want the PDF to be downloaded. I just want the name to be dynamic when user tries to Save the PDF? Am I missing something here.
Thank You in advance for your help!!
Regards,
Sravan.
Hi Ramu,
I have used Apexpages.currentPage().getHeaders().put('content-disposition', 'inline; filename=Testfilename.pdf'); in the controller and it worked perfectly.
If the requirement is to download the file use Apexpages.currentPage().getHeaders().put('content-disposition', 'Attachment; filename=Testfilename.pdf');
Thank You for the response.
Regards,
Sravan.
All Answers
Hi Ramu,
I have used Apexpages.currentPage().getHeaders().put('content-disposition', 'inline; filename=Testfilename.pdf'); in the controller and it worked perfectly.
If the requirement is to download the file use Apexpages.currentPage().getHeaders().put('content-disposition', 'Attachment; filename=Testfilename.pdf');
Thank You for the response.
Regards,
Sravan.