use*_*256 2 c# asp.net pdf-generation export-to-pdf
我正在尝试使用ASP.NET(C#)将检索到的数据从SQL导出为PDF.备注:
如何使用ASP.NET将HTML表格转换为PDF?
谁能帮我?谢谢.
小智 5
您可以尝试使用itextsharp(链接)
例:
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using iTextSharp.text.html;
// step 1 -- get html content
string htmlContent = ... // you html code (for example table from your page)
Document document = new Document();
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter.GetInstance(document, new FileStream("c:\\Chap0101.pdf", FileMode.Create));
// step 3: we open the document
document.Open();
// step 4: we add a paragraph to the document
//document.Add(new Paragraph(htmlContent.ToString()));
System.Xml.XmlTextReader _xmlr = new System.Xml.XmlTextReader(new StringReader(htmlContent));
HtmlParser.Parse(document, _xmlr);
// step 5: we close the document
document.Close();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17801 次 |
| 最近记录: |