Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I am rendering an mvc aspx view to a pdf where the header is overlapping the content in the second page and other pages except the first page where as in the first page it is working fine .
Here is my code
string footer1 = "--header-left \"Shipper No: " + viewModel.ShipperNo + " " + "Attention: " + viewModel.AttentionTo + "\n" + "Date: " + viewModel.SubmittedDate + " " + "Location: " + viewModel.Location + "\n" + "Shipper Type: " + viewModel.ShipperType
+ " " + "Address: " + viewModel.Address + "\n" + "Order Completed: " + viewModel.OrderCompleted + " " + "City/Sate/Zip: " + viewModel.City_State_Zip + " " + "Page: [page] of [toPage]\"";

return new ViewAsPdf("ExporttoPDF", viewModel) { CustomSwitches = footer1 };
Please help me on this.

What I have tried:

I am able to render the the view to a pdf but header text is overlapping in the second page.
Posted
Updated 11-Oct-17 21:22pm

1 solution

This is my aspx view

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<MVCECUDataTrackingSystem.ViewModels.ShippingViewModel>" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <meta name="viewport" content="width=device-width" />
    <title>ExporttoPDF</title>
                                         <h2 style="text-align:right">Shipper</h2>
</head>
<body>
<%--<h2 style="text-align:center">Shipper</h2>--%>
<%-- style="page-break-after:always"--%>
   <div id="divExport">
     <table style="height:100px;"></table>
   <table  style=""> 
   <pre lang="text"><%--<tr><td>Shipper No</td><td><%:Html.DisplayFor(model => model.ShipperNo)%></td><td
> Attention <%:Html.DisplayFor(model => model.AttentionTo)%>
Date<%:Html.DisplayFor(model => model.SubmittedDate)%> Location<%:Html.DisplayFor(model => model.Location)%>
Shipper Type<%:Html.DisplayFor(model => model.ShipperType)%> Address<%:Html.DisplayFor(model => model.Address)%>
Order Completed<%:Html.DisplayFor(model => model.OrderCompleted)%> City/State/Zip<%:Html.DisplayFor(model => model.City_State_Zip)%>
GEE Program No<%:Html.DisplayFor(model => model.GEEProgramNo)%>WBS No<%:Html.DisplayFor(model => model.WBSNo)%>
Customer No<%:Html.DisplayFor(model => model.CustomerNo)%>OUC<%:Html.DisplayFor(model => model.OUCNo)%> --%>
<%-- Comment <%:Html.TextAreaFor(model => model.CustomerNo, new { })%>--%>

Comment <%:Html.DisplayFor(model => model.CustomerNo, new {Style="width:1125px" })%>





<% foreach (var item in Model.ShipDetails)
{%>
<%-- page-break-inside: avoid--%>








<% } %>
ECS IDPart NoSerial NoBuffersBuffer Part NoBuffer Serial NoPart NameAmount(In Dollars)
<%:item.ECSID%><%: item.PartNo%><%: item.SerialNo%><%: item.Buffers%><%: item.BufferPartNo%><%: item.BufferSerialNo%><%: item.PartName%><%: item.Amount%>









Shipper:
Print Name:<%:Html.DisplayFor(model => model.UserName)%>_________________________________ Signature:_________________________________ Date:___________
Receiver:
Print Name:_________________________________ Signature: _________________________________ Date:_____________



<%--
<%:Html.ActionLink("Download PDF", "DownloadPDF", new { shipId = Model.ShipperNo })%>
--%>
<%-- <% }%>--%>
<%-- <% }%>--%>
 
Share this answer
 
Comments
Richard Deeming 12-Oct-17 13:18pm    
How is this supposed to be a "solution" to your question?!

If you want to update your question, click the green "Improve question" link and edit your question. DO NOT post the update as a "solution".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900