2

razorpdf を使用して、mvc 4 アプリケーションで PDF レポートを生成しています。PDFを生成するたびに、説明フィールドに表示されないはずのhtmlタグとフィールドがたくさん表示されます。説明フィールドのプレーンテキストを表示したいだけです。これを行う方法についてのアドバイスや、pdfページに画像を追加する方法についてのアドバイスはありますか?

これは、pdfを生成している私の見解です:

@model List<ArdentMC.DHS.COP.Mobile.MVC.Models.Reports>
@{
Layout = "";
}
<!DOCTYPE html>
<html>
<head>
    <div style="color=red; align:center;">UNCLASSIFIED/FOR OFFICAL USE ONLY</div>

</head>
<body>

<table style="width:300px;">
   @foreach (var item in Model)
{
<tr>
<td>@item.Phase</td>
<td>@item.NocNumber</td>
<td>@item.Title</td>
<td>@item.Location</td>
</tr>
    <tr<
    <td></td>
    <td></td> 
    <td>@item.ReportDateText</td>
    <td>@item.Description</td>
    </tr>     
}
</table>                             
    <br /><br /><br /><br /><br />
    <br /><br /><br /><br /><br />
     <div style="color:black; align:center;">US Department of Homeland Security</div>
        <br />
        <div style="color:red; align:center;">UNCLASSIFIED/FOR OFFICAL USE ONLY</div>

</body>
</html>

これは、情報が取得される私のモデルです:

          using System;
          using System.Collections.Generic;
          using System.Linq;
          using System.Web;

       namespace ArdentMC.DHS.COP.Mobile.MVC.Models
    {
public class Reports
{
    public string NocNumber { get; set; }
    public string Title { get; set; }
    public Nullable<System.DateTime> IncidentDate { get; set; }
    public string ReportDateText { get; set; }
    public string IncidentType { get; set; }
    public Nullable<int> IncidentSubtypeId { get; set; }
    public string IncidentSubtype { get; set; }
    public Nullable<int> PhaseId { get; set; }
    public string Phase { get; set; }
    public string InitialNotification { get; set; }
    public string Location { get; set; }
    public string NocSpotRep { get; set; }
    public string Contributors { get; set; }
    public string Participants { get; set; }
    public string Description { get; set; }
    public Nullable<int> IncidentStateId { get; set; }
    public string IncidentState { get; set; }
    public Nullable<System.DateTime> PublishDate { get; set; }
    public Nullable<System.DateTime> ArchiveDate { get; set; }

    }
}

説明テキストを表示する方法について誰かアドバイスがありますか? 前もって感謝します。

4

2 に答える 2

4

ビューに @foreach (var item in Model){ @Html.Raw(item.Description) } を追加すると、説明フィールドの正しいコードがレンダリングされ、表示可能なタグがなく、テキストのみが表示されました。

于 2014-04-08T23:47:41.060 に答える
-1
public ActionResult NotFound() {
    Response.ContentType = "text/html";
    return View();
}
于 2020-10-29T13:54:31.827 に答える