TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Pramod M
NA
81
9.8k
Download HTML Content as PDF
Aug 26 2019 8:03 AM
function NoDueCertificatePDFDownload(value) {
var pdfdoc = new jsPDF('l', 'pt', 'a4');
var specialElementHandlers = {
'#ignoreContent': function (element, renderer) {
return true;
}
};
printHtmlToPdf(document.getElementById(value).innerHTML);
localStorage.setItem('load', 'false');
}
function printHtmlToPdf(html) {
localStorage.setItem('load', 'true');
var endpoint = 'https://v2018.api2pdf.com/chrome/html';
var apikey = '8ac65d3a-f0fe-4e1b-9a6b-d28de90b';
var payload = {
"html": html,
"inlinePdf": false
};
$.ajax({
url: endpoint,
method: "POST",
dataType: "json",
crossDomain: true,
contentType: "application/json; charset=utf-8",
data: JSON.stringify(payload),
cache: false,
beforeSend: function (xhr) {
/* Authorization header */
xhr.setRequestHeader("Authorization", apikey);
},
success: function (data) {
//console.log(data.pdf); //this is the url to the pdf, do something with it
window.location = data.pdf;
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
}
Without apikey need to download HTML as PDF Download.
Reply
Answers (
3
)
Print table using two ngFor loop
Why you should consider integrating AngularJS with Magento 2