【问题标题】:Writing content of HTML table into PDF doc using iTextSharp in asp.net在 asp.net 中使用 iTextSharp 将 HTML 表格的内容写入 PDF 文档
【发布时间】:2013-07-20 12:28:08
【问题描述】:

我有一个存储在字符串中的 HTML 表。我想使用 iTextSharp 库将该字符串写入 PDF 文档。请提出方法。下面是我想写成PDF文件的表格

<table>
<tr>
        <th>test</th><td>&nbsp;&nbsp;</td><td>ABCD</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td>
    </tr><tr>
        <th>test 2</th><td>&nbsp;&nbsp;</td><td>XYZ</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td>
    </tr>
</table>

【问题讨论】:

    标签: asp.net c#-4.0 pdf-generation itextsharp


    【解决方案1】:

    这是可能的。 试试这个。

        //HTMLString = Pass your Html , fileLocation = File Store Location
        public void converttopdf(string HTMLString, string fileLocation)
        {
            Document document = new Document();
    
            PdfWriter.GetInstance(document, new FileStream(fileLocation, FileMode.Create));
            document.Open();
    
            List<IElement> htmlarraylist = HTMLWorker.ParseToList(new StringReader(HTMLString), null);
            for (int k = 0; k < htmlarraylist.Count; k++)
            {
                document.Add((IElement)htmlarraylist[k]);
            }
    
            document.Close();
        }
    

    【讨论】:

    • 表示生成的pdf文件你想在你的系统上下载?
    • 我得到了解决方案,谢谢你的帮助。
    • 这将在我的页面中显示错误.. 你能告诉我我们可以在上面使用哪个 dll
    • 这个可以免费用于商业用途吗?
    猜你喜欢
    • 2014-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多