HTML to PDF
How do I make an html to pdf?
Simple code to export a specific area from page to PDF. What is a html to pdf? How do you make a html to pdf? This script and codes were developed by Michel Makei Gefuni on 07 December 2022, Wednesday.
HTML to PDF - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>HTML to PDF</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container form" id="form"> <div class="row title hidden-print"> <div class="col-sm-6"> <h1>HTML to PDF</h1> </div> <div class="col-sm-6 text-right"><a class="btn btn-success" id="exportForm">Export page</a></div> </div> <div id="first-page"> <div class="row title"> <div class="col-sm-12"> <h2>First Page</h2> </div> </div> <div class="row"> <div class="col-sm-3 form-group"> <label>First Name</label> <input class="form-control"/> </div> <div class="col-sm-3 form-group"> <label>Last Name</label> <input class="form-control"/> </div> <div class="col-sm-3 form-group"> <label>Birthday</label> <input class="form-control"/> </div> <div class="col-sm-3 form-group"> <label>Email Address</label> <input class="form-control"/> </div> </div> <div class="row hidden-print"> <div class="col-sm-12 form-group"> <label>Bio</label> <textarea class="form-control"></textarea> </div> </div> </div> <div id="second-page"> <div class="row title"> <div class="col-sm-12"> <h2>Second Page</h2> </div> </div> <div class="row"> <div class="col-sm-3 form-group"> <label>First Name</label> <input class="form-control"/> </div> <div class="col-sm-3 form-group"> <label>Last Name</label> <input class="form-control"/> </div> <div class="col-sm-3 form-group"> <label>Birthday</label> <input class="form-control"/> </div> <div class="col-sm-3 form-group"> <label>Email Address</label> <input class="form-control"/> </div> </div> <div class="row"> <div class="col-sm-12 form-group"> <label>Bio</label> <textarea class="form-control"></textarea> </div> </div> </div>
</div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
HTML to PDF - Script Codes CSS Codes
body { padding: 10px;
}
* { background-color: #fff;
}
h1 { margin-top: 0;
}
h2 { margin-top: 40px;
}
.form { padding: 20px;
}
.form .title { margin-bottom: 60px;
}
.form .row:nth-child(even) { padding-bottom: 20px; margin-bottom: 30px; border-bottom: #ccc thin solid;
}
HTML to PDF - Script Codes JS Codes
$('#exportForm').click(function(){ var pdf = new jsPDF('a', 'mm', 'a4'); var firstPage; var secondPage; html2canvas($('#first-page'), { onrendered: function(canvas) { firstPage = canvas.toDataURL('image/jpeg', 1.0); } }); html2canvas($('#second-page'), { onrendered: function(canvas) { secondPage = canvas.toDataURL('image/jpeg', 1.0); } }); setTimeout(function(){ pdf.addImage(firstPage, 'JPEG', 5, 5, 200, 0); pdf.addPage(); pdf.addImage(secondPage, 'JPEG', 5, 5, 200, 0); pdf.save("export.pdf"); }, 150);
});
Developer | Michel Makei Gefuni |
Username | michelgefuni |
Uploaded | December 07, 2022 |
Rating | 3 |
Size | 2,946 Kb |
Views | 6,072 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Simple Accordion JQuery | 3,131 Kb |
Charts using ChartJS | 2,450 Kb |
Columns with equal height | 1,990 Kb |
Arrow CSS | 1,712 Kb |
Display a form from a select | 3,732 Kb |
Responsives Squares CSS | 2,430 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Sassy Buttons | Elyseholladay | 2,299 Kb |
Pericles mi loro... | Judag | 4,125 Kb |
Parallax.js | Zmeeey5 | 2,330 Kb |
We Simplify animation | Meodai | 48,169 Kb |
Experiments with Vertical Centering | KatieK2 | 3,924 Kb |
Login with flip 3d animation | Mariusbalaj | 3,014 Kb |
Pink expansion tunnel | Vez | 1,738 Kb |
Angular Sandbox | Alexgurrola | 1,616 Kb |
Responsive slide | Thorien | 2,400 Kb |
Twitch API | Coderpilot | 3,412 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!