How to generate PDF from HTML view after scripts and styles applied in ASP.NET MVC

前端 未结 3 782
生来不讨喜
生来不讨喜 2021-01-15 14:57

I want to generate HTML of my View to generate PDF document. It has styles and scripts applied when it opens in browser. I tried the following code but it only gives the ht

3条回答
  •  旧巷少年郎
    2021-01-15 15:51

    If you want user to download the pdf of rendered page then the easiest solution to the problem is

    window.print(); 
    

    on client side it will prompt user to save pdf of current page. You can also customize the appearance of pdf by linking style

    
    

    print.css is applied to the html while printing.

    Limitation

    1. You can't store the file on server side.
    2. User prompt to print the page than he had to save page manually.
    3. Page must to be rendered in a tab.

提交回复
热议问题