Page 1 of 1

How to hide a custom button when you export to pdf

Posted: 22 Mar 2017
by jpwallace
I have created a custom button which will export my form to PDF, however the button itself is included on the pdf, how do I remove the button so it doesn't appear in the exported PDF.

I am currently using on the button onclick - fd.saveAsPDF('filename');

Also each of my forms will have a unique number assigned to it, is there a way to change the 'filename' of the PDF so that it is dynamic to that certain unique numbered field in my form

Thanks

Re: How to hide a custom button when you export to pdf

Posted: 22 Mar 2017
by Dmitry Kozlov
Hi,
1. Assign a Css Class to the button, ex.: export-button.
2. Insert the code into OnClick property:

Code: Select all

$('.export-button').hide();
fd.saveAsPDF(fd.field('FieldName').value())
	.done(function() { $('.export-button').show(); });
Replace FieldName with the internal name of the field containing the unique number.

Re: How to hide a custom button when you export to pdf

Posted: 22 Mar 2017
by jpwallace
Brilliant, thank you this worked PERFECT!!

if I want my button to open up a display form in a dialog as well, where about and what would I include to the code you supplied

$('.export-button').hide();
fd.saveAsPDF(fd.field('FieldName').value())
.done(function() { $('.export-button').show(); });

Thank you again

Re: How to hide a custom button when you export to pdf

Posted: 23 Mar 2017
by Dmitry Kozlov
Hi,
Do you want to open a dialog after saving the form into PDF?

Re: How to hide a custom button when you export to pdf

Posted: 23 Mar 2017
by jpwallace
Hi Dimitry,

Ideally my aim is to have a "generate report" button on my edit form, and that saves the display form as a PDF

Re: How to hide a custom button when you export to pdf

Posted: 27 Mar 2017
by jpwallace
Hi Dmitry, Just wondered if you had any suggestions on what I need to include so I can open the display view of a form for a particular task and save as PDF

Re: How to hide a custom button when you export to pdf

Posted: 28 Mar 2017
by Dmitry Kozlov
Hi,
Open the display form with fd.openForm method, ex.:

Code: Select all

fd.openForm('fd_Item_Display.aspx');
And call fd.saveAsPDF method in the display form.
https://spform.com/documentation/js/manager