Reputation: 35
I have some HTML text, that I want to convert into PDF using some jquery plugin...
var pdf = new jsPDF('p', 'pt', 'a4');
pdf.addHTML($("#sectionId").get(0), 15, 15, options, function () {
pdf.save('@(Html.Raw("textdoc.pdf")'));
return true;
});
Upvotes: 0
Views: 1744
Reputation: 643
You could use tables of HTML to your side, it works with most of styles, such tool is called: mpdf. Atleast I was using it, and I didint have problems.
Upvotes: 0
Reputation: 1850
you can use docraptor library to do so
<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>
Here is the link also
Upvotes: 3