Mahesh Bodepudi

Mahesh Bodepudi

  • NA
  • 90
  • 56.9k

Export View to PDF in MVC

Sep 1 2017 6:08 AM
Hi,
I have a view which is binded by a model.Here actually my requirement to export that particular customized view with data should be printed in pdf,but on click of a link of each row in index view it should print pdf without going to view.
As of now I want to print the view in pdf.Please help me on this,I am using aspx view engine for this.
 
Please find the below code in view.
<input type="submit" value="Export" />
<div id="divExport">
<table style="width:100%">
<tr><td><b>Shipper No</b></td><td><%:Html.TextBoxFor(model=>model.ShipperNo) %></td><td></td><td></td><td><b>Attention</b></td><td><%:Html.TextBoxFor(model => model.AttentionTo)%></td></tr>
<tr><td><b>Date</b></td><td><%:Html.TextBoxFor(model => model.Date)%></td><td><b>Submitted Date</b></td><td><%:Html.TextBoxFor(model => model.SubmittedDate)%></td><td>Location</td><td><%:Html.TextBoxFor(model => model.Location)%></td></tr>
<tr><td><b>Shipper Type</b></td><td><%:Html.TextBoxFor(model => model.ShipperType)%></td><td> </td><td></td><td>Address</td><td><%:Html.TextBoxFor(model => model.Address)%></td></tr>
<tr><td><b>Order Completed</b></td><td><%:Html.TextBoxFor(model => model.OrderCompleted)%></td><td> </td><td> </td><td>City/State/Zip</td><td><%:Html.TextBoxFor(model => model.City_State_Zip)%></td></tr>
<tr><td><b>GEE Program No</b></td><td><%:Html.TextBoxFor(model => model.GEEProgramNo)%></td><td><b>WBS No</b></td><td><%:Html.TextBoxFor(model => model.WBSNo)%> </td><td> </td><td> </td></tr>
<tr><td><b>Customer No</b></td><td><%:Html.TextBoxFor(model => model.CustomerNo)%></td><td><b>OUC</b></td><td><%:Html.TextBoxFor(model => model.OUCNo)%> </td><td> </td><td> </td></tr>
<tr style="width:100%"><td style="width:100%"><b>Comment</b></td><td><%:Html.TextAreaFor(model => model.CustomerNo, new { })%></td></tr>
</table>
<table style="width:100%">
<tr><th><b>ECS ID</b></th><th><b>Part No</b></th><th><b>Serial No</b></th><th><b>Buffers</b></th><th><b>Buffer Part No</b></th><th><b>Buffer Serial No</b></th><th><b>Part Name</b></th><th><b>Amount(In Dollars)</b></th></tr>
<% foreach (var item in Model.ShipDetails)
{%>
<tr><td><%:item.ECSID %></td>
<td><%: item.PartNo %></td>
<td><%: item.SerialNo %></td>
<td><%: item.Buffers %></td>
<td> <%: item.BufferPartNo %></td>
<td> <%: item.BufferSerialNo %></td>
<td> <%: item.PartName %></td>
<td> <%: item.Amount %></td></tr>
<% } %>
</table>
<table style="width:100%">
<tr><td><b>Shipper:</b></td></tr>
<tr><td><b>Print Name:______Logging in (person)___ Signature:_________________________________ Date:___________</b></td></tr>
<tr><td><b>Receiver:</b></td></tr>
<tr><td><b> Print Name:____________________________ Signature: _____________________________________ Date:_____________</b></td></tr>
</table>
</div>
<% }%>
 
 
 

Answers (4)