4

C# MVC を使用して、HTML 部分ビューを PdfResult に渡してレポートを作成しています。これにより、ページ番号がないことを除けば、必要なものが正確に提供されます。

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>       
4

2 に答える 2

1

Nick が示唆する簡単な答えは NO です。RazorPDF は、ドキュメントにページ番号を自動的に追加する機能をサポートしていません。

RazorPDF は iTextSharp の古いバージョンを使用していますが、これは最新の無料の iTextSharp バージョンであると私は信じています。最新バージョン (5.5.5) は、AGPL ライセンスの下で入手できます。

RazorPDF の最新の iTextSharp バージョン

パッケージ id="iTextSharp" バージョン="4.1.2" targetFramework="net40"

HTML のレンダリングが問題にならない場合は、PDFsharp と MigraDoc をご覧ください。MigraDoc は、ここに示すようにページ番号付け機能を提供します。

お役に立てれば。

于 2015-04-23T13:48:56.610 に答える