我正在尝试创建包含一个
- 可编辑的 cshtml 视图页面
接着
- 单击按钮后,将编辑后的内容保存为 PDF
所以这是整个cshtml视图页面,
@model IEnumerable<int>
@{
ViewBag.Title = "Create Template";
}
<!DOCTYPE html>
<html>
<head>
<title>Create a Template</title>
</head>
<body>
<div id='template'>
<h1 contentEditable='True'>Product Name</h1>
<div >
<h2 contentEditable='True'>Product Description</h2>
<p contentEditable='True'>London is the capital city of England.</p>
</div>
</div>
<button id="btn_sumbit" type="button" class="btn btn-danger submit">Save as PDF</button>
</body>
</html>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/jqueryui")
<script type="text/javascript">
$('#btn_sumbit').on('click', function () {
var div_value = document.getElementById('template').innerHTML;
RazorPDF.PdfResult(div_value, "PDF");
});
</script>
}
我正在使用RazorPDF来执行此任务,但是一旦单击此按钮,它就不会保存为 PDF
我可以编辑这个 cshtml 视图页面,我想将最终编辑的内容保存为 pdf(这是动态视图)