You need to sign in to do that
Don't have an account?

How to download the PDF in new tab when a button is clicked in custom vfpage
Hi all,
I want to download the PDF in the new tab when a button in custom vfpage is clicked. Can anyone help me over here.
I want to download the PDF in the new tab when a button in custom vfpage is clicked. Can anyone help me over here.
You can use commandLink instead of a commandbutton. You can use the style attribute to make it look like a button
<apex:commandLink action="{!controllerMethod}" target="_blank" value="Link to Attachment" id="theButton" styleclass="btnImportant"/>
Hope this helps! If you think this resolved your issue, kindly select this as the answer to help the community!
Thanks
Santosh Kumar Sriram
All Answers
You can use target="_blank" to redirect to new page on clicking link
<apex:commandbutton value="Link to Attachment" action="{!controllerMethod}" target="_blank"/>
Let me know if it helps you.
Regards,
Onesh.K
Thanks for the reply. I have have already tried it. Getting error as
Error: Unsupported attribute target in <apex:commandbutton>
Could you post the code for custom vf page, might be easy to help
<apex:commandbutton action="{!getpdfpage}" value="PDF" target="_blank"/>
Method in class:
public PageReference getpdfpage() {
this.ugId = ApexPages.currentPage().getParameters().get('id');
Pagereference ref = new Pagereference('/apex/UG_PDF_Page?id=' +this.ugId);
ref.setRedirect(true);
// if successfully inserted new lform, then displays the thank you page.
return ref;
}
It would be great if you will share the Issue in more detail.
Like what issue are you facing and what happens when you clicks the buttons.
Thanks
You can use commandLink instead of a commandbutton. You can use the style attribute to make it look like a button
<apex:commandLink action="{!controllerMethod}" target="_blank" value="Link to Attachment" id="theButton" styleclass="btnImportant"/>
Hope this helps! If you think this resolved your issue, kindly select this as the answer to help the community!
Thanks
Santosh Kumar Sriram