Hi Bot help me. Here's my source code and showing the error Uncaught ReferenceError: jsPDF is not defined.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="You do not have permission to view the full content of this post. Log in or register now."></script>
<script src="You do not have permission to view the full content of this post. Log in or register now."></script>
<script src="You do not have permission to view the full content of this post. Log in or register now."></script>
</head>
<body>
<button id="generate-pdf">Generate PDF</button>
<script>
$(document).ready(function() {
var jsonData = [
// Your JSON data here
];
$('#example').DataTable({
data: jsonData,
columns: [
{ data: 'field1' },
{ data: 'field2' },
// Add more columns as needed
]
});
$('#generate-pdf').click(function() {
var doc = new jsPDF();
// Add image
var imgData = 'You do not have permission to view the full content of this post. Log in or register now.
doc.addImage(imgData, 'JPEG', 10, 10, 50, 50); // Adjust the positioning and size of the image
// Add header
var headerText = 'My PDF Header';
doc.setFontSize(18);
doc.text(headerText, 10, 80); // Adjust the positioning of the header text
// Get the data from DataTables
var tableData = $('#example').DataTable().data();
// Iterate over the data and add it to the PDF
$.each(tableData, function(index, data) {
doc.text(data.field1 + ', ' + data.field2, 10, 100 + (index * 10)); // Customize the positioning of the text
});
// Add footer
var footerText = 'Page ' + doc.internal.getCurrentPageInfo().pageNumber;
doc.setFontSize(10);
doc.text(footerText, 10, doc.internal.pageSize.height - 10); // Adjust the positioning of the footer text
// Save the PDF file
doc.save('data.pdf');
});
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="You do not have permission to view the full content of this post. Log in or register now."></script>
<script src="You do not have permission to view the full content of this post. Log in or register now."></script>
<script src="You do not have permission to view the full content of this post. Log in or register now."></script>
</head>
<body>
<button id="generate-pdf">Generate PDF</button>
<script>
$(document).ready(function() {
var jsonData = [
// Your JSON data here
];
$('#example').DataTable({
data: jsonData,
columns: [
{ data: 'field1' },
{ data: 'field2' },
// Add more columns as needed
]
});
$('#generate-pdf').click(function() {
var doc = new jsPDF();
// Add image
var imgData = 'You do not have permission to view the full content of this post. Log in or register now.
doc.addImage(imgData, 'JPEG', 10, 10, 50, 50); // Adjust the positioning and size of the image
// Add header
var headerText = 'My PDF Header';
doc.setFontSize(18);
doc.text(headerText, 10, 80); // Adjust the positioning of the header text
// Get the data from DataTables
var tableData = $('#example').DataTable().data();
// Iterate over the data and add it to the PDF
$.each(tableData, function(index, data) {
doc.text(data.field1 + ', ' + data.field2, 10, 100 + (index * 10)); // Customize the positioning of the text
});
// Add footer
var footerText = 'Page ' + doc.internal.getCurrentPageInfo().pageNumber;
doc.setFontSize(10);
doc.text(footerText, 10, doc.internal.pageSize.height - 10); // Adjust the positioning of the footer text
// Save the PDF file
doc.save('data.pdf');
});
});
</script>
</body>
</html>