Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have Html Table Row and i want save to pdf file...I wrote the code, but no action and no error message...can anybody help me

What I have tried:

HTML
<!doctype html>
<html>
<head>
	<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
</head>
<body>
	<center>
<table class="table table-bordered" id="tabledata">
	
	<tr>	
	<th>slno</th>
	<th>name</th>
	</tr>

	<tr>
	<td>1</td>
	<td>Antony</td>
	</tr>
	
	<tr>
	<td>2</td>
	<td>Sophia</td>
	</tr>
	
	<tr>
	<td>3</td>
	<td>Angela</td>
	</tr>
	
	</table>

	</center>


	<center>
	<button class="btn btn-sucess" onClick="downloadDoc()">Download PDF</button>
	</center>
	
<script type="text/javascript" src="lib/jquery.min.js"></script>
<script type="text/javascript" src="lib/jspdf.debug.js"></script>
<script type="text/javascript" src="lib/html2canvas.js"></script>
	
	
	
	
	<script type="text/javascript">
		function downloadDoc(){
			html2canvas($("#tabledata")[0],{
				onrendered:function(canvas){
					var data=canvas.toDataURL();
					var docDefinition={
						content:[{
							image:date,
							width=500	
						}]								
					};
					pdfMake.CreatePdf(DocDefinition).download("Table.pdf");
				}
			})
		}
		
	</script>
	
</body>
</html>
Posted
Updated 22-Nov-23 2:30am
v2
Comments
Andre Oosthuizen 24-Nov-23 12:50pm    
Your code does not show any means of saving a file, only to download it, maybe that is where you need to start looking for a solution.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900