Ali*_*oto 4 asp.net asp.net-mvc rotativa
我有一份报告,它通常在带有 css 的本地主机中工作。但是当我放在服务器上时,不会使用捆绑包加载CSS。
代码 :
public ActionResult ParseSendPDF()
{
var result = Session["Search"] as List<Order>;
ViewAsPdf pdf = new ViewAsPdf("SendPDF", result);
pdf.PageOrientation = Rotativa.Options.Orientation.Landscape;
pdf.PageSize = Rotativa.Options.Size.A4;
pdf.CustomSwitches = "--background";
foreach (var results in result)
{
foreach (var detail in results.OrderDetails)
{
var description = detail.Description;
if (description.Length > 84)
{
SetBreakLine(ref description);
detail.Description = description;
}
}
}
return pdf;
}
Run Code Online (Sandbox Code Playgroud)
看法 :
@model List<Models.Order>
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Reports</title>
@Styles.Render("~/Content/css")
@Styles.Render("~/Content/trip")
@Styles.Render("~/Content/datetimepicker")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/ajax")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/datetimepicker")
<style type="text/css">
table { page-break-inside:auto }
tr { page-break-inside:avoid; page-break-after:auto }
thead { display:table-header-group }
tfoot { display:table-footer-group }
</style>
</head>
<body>
<img style="margin-top: -7px;" class="img-responsive" src="~/Content/Images//logo.png" />
<h1 class="text-center">Reports</h1>
@Html.Partial("_Index", Model)
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在本地主机中工作但在服务器中,我的 CSS 和徽标不起作用。
我花了几周的时间来解决这个问题,并且尝试了 Stack Overflow 提供的所有建议:
最后,我最终删除了捆绑包引用,并在布局页面标题中明确说明了我的 CSS 文件,并且它起作用了。
<link rel="stylesheet" type="text/css" href="~/Content/bootstrap.min.css"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5106 次 |
| 最近记录: |