【发布时间】:2020-12-08 09:45:16
【问题描述】:
我想在 cshtml 中显示动态标题。当我尝试使用 CustomSwitches 传递它时,我收到一个错误,例如 QPaintDevice: Cannot destroy paint device that is beingpaintingpure virtual method called terminate called without an active exception.
从 mvc 控制器调用 Rotativa 组件(它在类库中)以打印没有标题的动态视图可以正常工作,但不能使用标题。有没有办法解决这个问题?
感谢您的回答。
编辑:使用 Rotativa 的示例
字符串头 = $"/Header.cshtml";
var customSwitches = string.Format("--header-html "{0}" " + "--header-spacing "0" ", header);
var view = new ViewAsPdf(pdfView.ToViewRoute(culture), model: viewModel)
{
PageOrientation = option.PageOrientation,
IsGrayScale = option.IsGrayScale,
MinimumFontSize = option.MinimumFontSize,
PageSize = option.PageSize,
PageMargins = option.PageMargins,
CustomSwitches = customSwitches
};
return view;
【问题讨论】:
-
你能分享一些调用Rotativa组件的代码吗?因为我无法重现错误。
-
谢谢,我刚刚编辑了这个问题,并举例说明了我是如何使用它的。你有一个动态标题工作的例子吗?谢谢。
-
header是指pdf的第一页,还是pdf中每一页的head?
-
感谢您的回复。我需要在所有页面中使用相同的标题。
标签: c# razor asp.net-core-mvc pdf-generation rotativa