Skip to content Skip to sidebar Skip to footer

Editable Cshtml View Page Save As Pdf

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 csh

Solution 1:

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.

public ActionResult Pdf(string name, string description) {
    var product = new Product();
    product.Name = name;
    product.Description = description;

    var pdfResult = new PdfResult(product, "Pdf");

    return pdfResult;
}

Of course you need to create a Product-Class that holds the information.

In your Javascript part you can write:

location.href = @Url.Action("Pdf", "Controllername") + "?name=" + name + "&description=" + description;

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. ;-)

Post a Comment for "Editable Cshtml View Page Save As Pdf"