使用 C# MVC,我通过 PdfResult 传递 HTML 部分视图来创建报告。除了缺少页码之外,这正好提供了所需的内容。
GetDetails
只需调用一个返回结果列表的服务。然后printlist
使用结果列表作为模型调用视图(见下文)。
RazorPDF 是否提供在报告上添加页码的方法?
public ActionResult PrintReport(DateTime printDate)
{
var printModel = printController.GetDetails(printDate);
var pdfDoc = new PdfResult(printModel , "printlist");
return pdfDoc;
}
看法:
<paragraph style="font-family:Arial;font-size:18;">
<table width="100%" cellpadding="1.0" cellspacing="1.0" widths="5;5">
<row>
<cell borderwidth="0.5" left="false" right="false" top="false" bottom="false">
<chunk style="font-size:14;font-weight:bold;">@ViewBag.Title</chunk>
</cell>
<cell borderwidth="0.5" left="false" right="false" top="false" bottom="false" horizontalalign="Right">
<chunk style="font-size:14;font-weight:bold;">@Model.First().appointment_date.ToString().Substring(0,10)</chunk>
</cell>
</row>
</table>
</paragraph>
<table width="100%" cellpadding="1.0" cellspacing="1.0" widths="4;10;7;14;4;4;4;3;4;4;4;4">
<row>
<cell borderwidth="0.5" left="false" right="false" top="true" bottom="true"><chunk>Time</chunk></cell>
<cell borderwidth="0.5" left="false" right="false" top="true" bottom="true"><chunk>Name</chunk></cell>
<cell borderwidth="0.5" left="false" right="false" top="true" bottom="true"><chunk>Number</chunk></cell>
<cell borderwidth="0.5" left="false" right="false" top="true" bottom="true"><chunk>Reason</chunk></cell>
</row>
@foreach (var item in Model)
{
<row>
<cell>@item.appointmentStart</cell>
<cell>@item.surname,@item.forename</cell>
<cell>@item.customerIdentifier</cell>
<cell>@item.reason</cell>
</row>
}
</table>