如何在MVC中使用rotativa减少pdf中的重叠文本 [英] How to reduce overlapping text in pdf using rotativa in MVC
问题描述
我将mvc aspx视图呈现为pdf,其中标题与第二页中的内容重叠,而除第一页之外的其他页面与第一页中的内容重叠很好。
这是我的代码
string footer1 = - header-left \发货人编号:+ viewModel.ShipperNo ++注意: + viewModel.AttentionTo +\ n+ +Date:+ viewModel.SubmittedDate ++Location:+ viewModel.Location +\ n+Shipper Type:+ viewModel.ShipperType
++地址:+ viewModel.Address +\ n+订单已完成:+ viewModel.OrderCompleted ++City / Sate / Zip:+ viewModel.City_State_Zip + +页面:[toPage] \的[页面];
返回新的ViewAsPdf(ExporttoPDF,viewModel){CustomSwitches = footer1};
请帮帮我。
我尝试了什么:
我能够将视图渲染为pdf但是标题文本在第二页重叠。
这是我的aspx视图
<%@ Page Language =C#Inherits =System.Web.Mvc.ViewPage< MVCECUDataTrackingSystem.ViewModels.ShippingViewModel> %GT;
<!DOCTYPE html>
< html>
< head runat =server>
< meta name =viewportcontent =width = device-width/>
< title> ExporttoPDF< / title>
< h2 style =text-align:right>发货人< / h2>
< / head>
< body>
<% - < h2 style =text-align:center>托运人< / h2> - %>
<% - style =page-break-after:always - %>
< div id =divExport>
< table style =height:100px;>< / table>
< table style =>
< pre lang =text><% - < tr>< td> 发件人否< / td>< td><%:Html .DisplayFor(model => model.ShipperNo)%>< / td>< td> 注意<%:Html.DisplayFor(model => model.AttentionTo)%>
日期<%:Html.DisplayFor (model => model.SubmittedDate)%> 位置<%:Html.DisplayFor(model => model.Location)%>
托运人类型<%:Html。 DisplayFor(model => model.ShipperType)%> 地址<%:Html.DisplayFor(model => model.Address)%>
订单已完成<%:Html。 DisplayFor(model => model.OrderCompleted)%> 城市/州/邮编<%:Html.DisplayFor(model => model.City_State_Zip)%>
GEE计划否< ;%:Html.DisplayFor(model => model.GEEProgramNo)%> WBS否<%:Html.DisplayFor(model => model.WBSNo)%>
客户编号<%:Html.DisplayFor(model => model.CustomerNo)%> OUC <%:Html。 DisplayFor(model => model.OUCNo)%> - %>
<% - 评论<%:Html.TextAreaFor(model => model.CustomerNo,new {})%> - - %>
评论 <%:Html.DisplayFor(model => model.CustomerNo,new {Style =width:1125px})%>
<%foreach(模型中的var项目。 ShipDetails)
{%>
<% - page-break-inside:忌 - %>
<%}%>
ECS ID 部件号 序列号 缓冲区 缓冲区部件号 缓冲区序列号 零件名称 金额(In美元) <%:item.ECSID%> <%:item.PartNo%> <%:item.SerialNo%> <%:item.Buffers%> <%:item.BufferPartNo%> <%:item.BufferSerialNo%> <%:item.PartName%> <%:item.Amount%>
托运人: 打印名称:<%:Html.DisplayFor( model => model.UserName)%> _________________________________签名:_________________________________日期:___________ < tr> 接收方: 打印名称:_________________________________签名:_________________________________日期:_____________
<% -<%:Html.ActionLink(下载PDF,DownloadPDF,新{shipId = Model.ShipperNo})%>- %>
<% - <%}%> - %>
<% - <%} %GT; - %GT;
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.
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 ID Part No Serial No Buffers Buffer Part No Buffer Serial No Part Name Amount(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 })%>--%>
<%-- <% }%>--%>
<%-- <% }%>--%>
这篇关于如何在MVC中使用rotativa减少pdf中的重叠文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!