I'm trying to create web application that consisting an
- editable cshtml view page
and then
- save that edited content as a PDF once I click the button
So this is the whole cshtml view page ,
@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>
}
I'm using RazorPDF to do this task , but once I click this button it doesn't saving to PDF
I can edit this cshtml view page , I want to save that finally edited content as pdf (which is dynamic view)
I think you're doing it wrong. The line "RazorPDF.PdfResult(...)" belongs in the Controller not in the View.
Watch this Video: http://nyveldt.com/blog/post/Introducing-RazorPDF It should give you a clearer understanding of how things work in RazorPDF.
EDIT:
Just create a Controller method, that generates a PDF-View based on Parameters.
Of course you need to create a Product-Class that holds the information.
In your Javascript part you can write:
This will hopefully generate a link that you can follow in Javascript. name and description are Javascript variables that hold the information that was typed by the user.
Do you understand? My approach would be to generate the PDF content in a different view (like in that video) based on the information of your editable view.
Tell me if it worked. ;-)