【发布时间】:2022-07-07 04:14:53
【问题描述】:
我在视图中有一个相当复杂的 html 代码,报告需要比默认的 30 秒更长的时间来生成结构。我正在使用 JSReport 2.7.1 版。最初,我尝试将 jsreport.config.json 文件从 "chrome": { "timeout": 180000 } 修改为一个非常大的数字,但没有奏效。
所以,我一直在尝试延长 jsreport 超时,这就是我所在的位置。
HttpContext.JsReportFeature()
.Recipe(Recipe.ChromePdf)
.Configure((r) => r.Template.Chrome = new Chrome
{
Landscape = true,
Format = "Legal",
HeaderTemplate = header,
FooterTemplate = footer,
DisplayHeaderFooter = true,
MarginTop = "95px",
MarginLeft = "20px",
MarginRight = "20px",
MarginBottom = "40px"
}
)
.Configure((r) => r.Options = new jsreport.Types.RenderOptions
{
Timeout = 600000
});
在上述情况下,样式有效,但未实现超时。但是,如果我颠倒配置的顺序并将超时放在首位,然后是样式,则超时有效,但样式无效。
我也尝试了下面的方法,即使在这里,也可能是没有样式的报告加载或超时并出现错误“JsReportBinaryException:错误呈现报告:正在启动渲染过程..渲染完成并出现错误:严重错误尝试执行渲染命令时发生 (2). Timeout Error: pdf generation not completed after 30000ms (1). 由于错误 (2):-> stackError: at onCriticalError (D:\snapshot\jsreport\node_modules\jsreport- cli\lib\commands\render.js:302:19) 在 D:\snapshot\jsreport\node_modules\jsreport-cli\lib\commands\render.js:298:12 由错误 (1) 引起:-> meta = { "workerTimeout":true,"logged":true}-> stackError: at Timeout. (D:\snapshot\jsreport\node_modules\jsreport-chrome-pdf\lib\conversion.js:293:19) at listOnTimeout (internal/ timers.js:549:17) 在 processTimers (internal/timers.js:492:7)"
HttpContext.JsReportFeature()
.Recipe(Recipe.ChromePdf)
.Configure(cfg =>
{
cfg.Options = new RenderOptions
{
Timeout = 600000
};
cfg.Template.Chrome = new Chrome
{
Landscape = true,
Format = "Legal",
HeaderTemplate = header,
FooterTemplate = footer,
DisplayHeaderFooter = true,
MarginTop = "95px",
MarginLeft = "20px",
MarginRight = "20px",
MarginBottom = "40px",
PrintBackground = true
};
})
有没有一种方法可以将两者结合起来并同时工作?
【问题讨论】:
-
我相信你在配置文件中设置了它。
-
@sairfan 我尝试在 jsreport.config.json 文件中更改它,但这并没有解决问题。超时更改没有发生,我得到了同样的错误。
-
你在使用 asp.net core 对吗?此配置用于 asp.net 网络应用程序
<httpRuntime targetFramework="4.5" maxRequestLength="2000000" />
标签: jsreport