HTML document to PDF?

后端 未结 6 960
臣服心动
臣服心动 2020-12-29 00:55

I\'ve got an ASP.NET web page that is a dynamically generated report. For business reasons, this exact report needs to be produced as a PDF. What\'s the best way to do this?

6条回答
  •  执笔经年
    2020-12-29 01:31

    Have you looked at SQL Server Reporting Services? If you are using MSSQL 2005/2008 then you probably already have reporting services and you just need to configure it. You can host your reports there and in just a few lines of code get the report as a PDF file.

        //create the web request for the report based on a URL that will define export 
        //format, parameter values, etc.
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(reportUrl);
        //send creditials if necessary
        request.Credentials = new NetworkCredential(userName, password);
        //response will contain the PDF file as a stream
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    

    Here is a link that might help as well

提交回复
热议问题