Reputation: 109
I am using razorpdf to generate a pdf report in my mvc 4 application. each time I generate the pdf, the description field will display a bunch of html tags and fields that are not supposed to be shown, i just want the plain text from the description field displayed. does anyone have any advice on how to do this, also any advice on how to add an image into the pdf page as well?
this is my view that is generating the 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>
this is my model where the information is getting pulled from:
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; }
}
}
does anyone have some advice on how to just get the description text to display? thank you in advance.
Upvotes: 2
Views: 1157
Reputation: 39
public ActionResult NotFound() {
Response.ContentType = "text/html";
return View();
}
Upvotes: -1
Reputation: 109
I was able to add @foreach (var item in Model){ @Html.Raw(item.Description) } into my view and that rendered the correct code for the description field so that there are no viewable tags, only text.
Upvotes: 4