Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Export To PDF In SharePoint
WhatsApp
Guest User
7y
34.4
k
0
0
25
Blog
Create a Web page retrieving content from the various lists.
Add a button called Export to PDF in an HTML file.
Set the onclick event for the button, as shown below.
<div>
<br>
<input type=
"button"
id=
"exporttopdf"
value=
"Export to PDF"
onclick=
"exportSelectedItemsToPdf();"
style=
"display:none;"
/>
<span> </span><input type=
"button"
value=
"Print"
id=
"print"
style=
"display:none"
onclick=
"PrintElem(this);"
/>
</div>
Here is the function representing linked to that button and gets executed when triggered.
function
exportSelectedItemsToPdf() {
var
documentPDF =
new
jsPDF();
var
caseid = $(
"#caseid_lb"
).text();
var
specialElementHandlers = {
'#editor'
:
function
(element, renderer) {
return
true
;
}
};
documentPDF.fromHTML($(
'#tab-5'
).html(), 15, 15, {
'width'
: 600,
'elementHandlers'
: specialElementHandlers
});
documentPDF.save(
'Case Id - '
+ caseid +
'.pdf'
);
}
Click the button for the result.
Here is the PDF, which gets downloaded.
Here is the PDF document when opened.
SharePoint
Up Next
Introduction To SharePoint 2016 Add-ins (aka apps)
Ebook Download
View all
Getting Started with SharePoint Framework Development using TypeScript, PnP JS, and React JS
Read by 4.9k people
Download Now!
Learn
View all
Membership not found