【发布时间】:2021-04-01 15:56:47
【问题描述】:
当我尝试在 linux - Ubuntu 18.04 的 asp net core mvc 中使用 Rotativa 时,我遇到了这个问题:
Exception: QPainter::begin(): Returned false Exit with code 1, due to unknown error.
在控制器中我有这个:
public IActionResult Utilidad(string fecha) {
var fechas = fecha.Split('-');
var ventasGeneradas = _ventaRepository.GetListado();
var modelo = new VentaBaseViewModel() {
ListaVentas = ventasGeneradas
};
return new ViewAsPdf("Utilidad", modelo) {
};
}
在启动时我有这个:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
if (env.IsDevelopment()) {
app.UseDeveloperExceptionPage();
// app.UseMigrationsEndPoint();
}
else {
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseForwardedHeaders(new ForwardedHeadersOptions {
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>{
endpoints.MapControllerRoute(
name: "default", pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapRazorPages();
});
Rotativa.AspNetCore.RotativaConfiguration.Setup(env.WebRootPath, "Rotativa");
}
我已经安装了包Rotativa.AspNetCore --version 1.2.0-beta,并且在wwwRoot 内的Rotativa 文件夹中我有wkhtmltoimage 和wkhtmltopdf。
我使用的是 NetCore 5.0 版
你能帮我解决这个问题吗?
【问题讨论】:
-
它可能在我的项目中运行良好。您错过了分享消息吗?错误是什么?类似:
QPainter::begin(): Returned false Error: Unable to write to destination Exit with code 1, due to unknown error. -
免责声明:我是 Rotativa.AspNetCore 的作者,也是 SaaS 服务 rotativa.io 的创建者。如果你想避免在服务器上运行 wkhtmltopdf 出现任何问题,你可以使用 rotativa.io,它只需要能够进行 HTTP 调用。该服务提供有限的免费订阅和更大负载的付费计划。
标签: c# asp.net-core model-view-controller rotativa