Spire PDF for. NET in ASP. NET, spireasp.net

Source: Internet
Author: User

Spire PDF for. NET in ASP. NET, spireasp.net

Note: Before reading this article, take a look at the previous article.

Yesterday, I tested the application of Spire PDF in the WinForm program. It can be said that it is easy to use (ignore the efficiency problem and do not perform the test ). However, when the Internet is so developed, the application of WEB is king. Therefore, today I try ASP. NET MVC4 again. Prepare to see if there are any differences in use.

Development Environment

Program running logic

 

Generate a simulated data source

 

1 [ActionName ("Generate")] 2 public ActionResult GenerateDynamicDataSource () 3 {4 return View (DynamicDataSourceDispatcher. GetDataSource (); 5}DataSource

 

 

Export

 
1 jsondocument documentInstance = new jsondocument (); 2 documentInstance. LoadFromHTML ("http: // localhost: 1/mvc4/controller/action = Generate", false, false, true );Spire PDF

 

Initial exception

According to the Code of yesterday, the code is basically over now, with only the output stream written to HttpResponse waiting for download. The results are not the same.

Long-lost Yellow Pages! What is this?

The literal meaning of the exception is what Active plug-in or COM component is accessed in Spire PDF.

No way, this can help the omnipotent du Niang (why not Google? The reason you know ). After checking for a long time, I finally saw a solution in a CSDN blog. In the @ Page command, specify the value of the AspCompat attribute to true.

ExportHandler. aspx

Helpless. Try it first to see if the yellow pages can be wiped out.

Put the code CtrlX + V above into the Page_Load on this page, "F5", actually solved the above problem.

        
1 protected void Page_Load (object sender, EventArgs e) 2 {3 your document documentInstance = new your document (); 4 documentInstance. loadFromHTML (HttpUtility. urlDecode (this. request. queryString ["targetperformanceuri"]), false, false, true); 5 this. response. contentType = "application/pdf"; 6 this. response. addHeader ("Content-Disposition", "attachment; filename = Spire PDF for aspnetmask"); 7 documentInstance. saveToStream (this. response. outputStream, FileFormat. PDF); 8}ExportHandler. aspx. cs

 

 

Suggestions

Running Effect

Code download

Https://sprepdfsdk2.codeplex.com/

 

Finally, thank you for your invitation to Yesi and the work of your team. We look forward to doing better in the Spire series!

Related Article

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.