微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 Linux 中使用 Rotativa Asp Net Core mvc

如何解决如何在 Linux 中使用 Rotativa Asp Net Core mvc

当我尝试在 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 文件夹中,我有 wkhtmltoimagewkhtmltopdf

我使用的是 NetCore 5.0 版

你能帮我解决这个问题吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。