Created
March 5, 2018 14:10
-
-
Save MdKutubuddinSardar/31e0909e67b3ab7bf3cf40c9f20d216c to your computer and use it in GitHub Desktop.
HTML-to-PDF with jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<script src="https://docraptor.com/docraptor-1.0.0.js"></script> | |
<script> | |
var downloadPDF = function() { | |
DocRaptor.createAndDownloadDoc("YOUR_API_KEY_HERE", { | |
test: true, // test documents are free, but watermarked | |
type: "pdf", | |
document_content: document.querySelector('html').innerHTML, // use this page's HTML | |
// document_content: "<h1>Hello world!</h1>", // or supply HTML directly | |
// document_url: "http://example.com/your-page", // or use a URL | |
// javascript: true, // enable JavaScript processing | |
// prince_options: { | |
// media: "screen", // use screen styles instead of print styles | |
// } | |
}) | |
} | |
</script> | |
<style> | |
@media print { | |
#pdf-button { | |
display: none; | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Example!</h1> | |
<input id="pdf-button" type="button" value="Download PDF" onclick="downloadPDF()" /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Converting HTML into PDF and XLS documents with jQuery is fast and painless with DocRaptor.