HTML code saved as PDF file

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.