The previous time Insus.net has implemented the "Upload text document and convert to PDF" http://www.cnblogs.com/insus/p/4313092.html and "Capture view section of the Save as partial view (partial view)" Http://www.cnblogs.com/insus/p/4323113.html. Now insus.net want to combine the above two to achieve another function, is to save the captured HTML as a PDF file.
In the previous article, converting a text document to PDF is a direct translation of the file. Now we don't have to save the HTML code as a file and then convert it. Use the Itextsharp component to convert a PDF, which can also be converted by a string. So we don't have to go around a circle.
In the controller, write a conversion of the operation of the PDF, the following two code is to convert the string to byte, the resulting byte has just matched the itextsharp of the transfer parameter type.
byte New byte sizeof (char00, bytes. Length);
View Code
Complete code example:
In the view, I add an ammonium button to modify the URL path:
Demonstrate:
HTML code saved as PDF file