PDF and Print Formatting

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
Jimmy Daresta
Posts: 13
Joined: Mon Aug 01, 2016

02 Aug 2016

I want when one prints or exports to PDF that the form(s) will be formatted differently. I have figured on the printing how to hide elements, but not on the PDF.


Also when I do print the form the font prints out much smaller than expected which I believe is due to the page not fitting size wise ont he page. How can I adjust the style of the print so the form fits on the page?

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

03 Aug 2016

Hi Jimmy,

Currently, you cannot handle exporting to PDF except using JavaScript:

Code: Select all

// hide elements you do not want to export
$('.to-hide').hide();

//export to PDF
fd.saveAsPDF('form.pdf')
    .then(function() {
    
        // show hidden elements
        $('.to-hide').show();
    });
As for printing, you can use CSS-styles applicable to printing forms only:

Code: Select all

@media print {
    // your CSS here
}
http://www.w3schools.com/css/css3_mediaqueries.asp

User avatar
Jimmy Daresta
Posts: 13
Joined: Mon Aug 01, 2016

03 Aug 2016

To clarify, I would need to add my own PDF export button? The one that shows in the ribbon would not work? I was hoping there was an onPDF() or a way to override the button action on the ribbon so I could then hide elements before rendering.

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

04 Aug 2016

If you want to use the ribbon button, you can override fd.saveAsPDF:

Code: Select all

var saveAsPDFOrig = fd.saveAsPDF;
fd.saveAsPDF = function(filename) {
    // hide elements
    return saveAsPDFOrig(filename)
        .then(function() {
            //show elements
        });
}

User avatar
Jimmy Daresta
Posts: 13
Joined: Mon Aug 01, 2016

04 Aug 2016

Perfect! Thank you!

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests