Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 在MVC中使用ItextSharp在PDF文档的每个页面上显示列标题_Asp.net Mvc_Razor_Itextsharp - Fatal编程技术网

Asp.net mvc 在MVC中使用ItextSharp在PDF文档的每个页面上显示列标题

Asp.net mvc 在MVC中使用ItextSharp在PDF文档的每个页面上显示列标题,asp.net-mvc,razor,itextsharp,Asp.net Mvc,Razor,Itextsharp,我一直在使用本指南创建PDF报告: 基本上我有一个表单,一旦提交,它就会创建并打开一个PDF报告 报告实际上是一个视图,例如: @using MvcReportGeneratorDemo.Models @model CustomerList <br /> <table cellpadding="3" cellspacing="3"> `<tr border="1" bgcolor="#777777" color="#ffffff">`

我一直在使用本指南创建PDF报告:

基本上我有一个表单,一旦提交,它就会创建并打开一个PDF报告 报告实际上是一个视图,例如:

@using MvcReportGeneratorDemo.Models
@model CustomerList
<br />
<table cellpadding="3" cellspacing="3">
    `<tr border="1" bgcolor="#777777" color="#ffffff">`
       <td>Name</td>
        <td>Address</td>
        <td>Place</td>
    </tr>
    @foreach (Customer customer in Model)
    {
        <tr border="1">
            <td>@customer.Name</td>
            <td>@customer.Address</td>
            <td>@customer.Place</td>
        </tr>
    }
</table>
使用MvcReportGeneratorDemo.Models @模型客户列表
`` 名字 地址 放置 @foreach(模型中的客户) { @顾客姓名 @客户地址 @顾客,地点 } 我希望PDF中的每个页面都有列标题,而不仅仅是第一个。
尝试了google,但没有发现任何相关信息。

您可以在服务器端使用以下代码来解决您的问题

using (StringReader sr = new StringReader(html))
        {

            foreach (IElement el in iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(sr, null))
            {

                if (el is PdfPTable)
                {
                    ((PdfPTable)el).HeaderRows = 1;
                }
                doc.Add(el);
            }
        }