How to hide a custom button when you export to pdf

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
jpwallace
Posts: 47
Joined: Fri Mar 03, 2017

22 Mar 2017

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

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

22 Mar 2017

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.

jpwallace
Posts: 47
Joined: Fri Mar 03, 2017

22 Mar 2017

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

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

23 Mar 2017

Hi,
Do you want to open a dialog after saving the form into PDF?

jpwallace
Posts: 47
Joined: Fri Mar 03, 2017

23 Mar 2017

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

jpwallace
Posts: 47
Joined: Fri Mar 03, 2017

27 Mar 2017

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

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

28 Mar 2017

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

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests