Problem using Rotativapdf on aspnet core 3

Asked

Viewed 21 times

-1

I have followed the recommended settings in the documentation, performed several searches, I have no error in the example but the report is not generated. Initially I did the installation of :

Install-Package Rotativa.AspNetCore -Version 1.2.0-beta

Startup Setup

RotativaConfiguration.Setup(env.WebRootPath, "Rotativa");

Example of my Home controller (Inside the Home folder, I have a View with the name = Visualizarpdf)

  public class Person
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    public string LastName { get; set; }
}


public IActionResult RotativaPDF()
{
    Person person = new Person()
    {
        Id = Guid.NewGuid(),
        Name = "Primeiro",
        LastName = "Ultimo"
    };


    var relatorioPDF = new ViewAsPdf
    {
        ViewName = "VisualizarPDF",
        IsGrayScale = false,
        FileName = "Fornecedor.pdf",
        PageOrientation = Rotativa.AspNetCore.Options.Orientation.Landscape,
        PageSize = Rotativa.AspNetCore.Options.Size.A4,
        Model = person
    };

    return relatorioPDF;
}


public IActionResult Index()
{
    RotativaPDF();
    return View();
}

1 answer

0


The solution and install the version

Install-Package Rotativa.AspNetCore -Version 1.1.1

In Startup just make the configuration:

//Configuração do rotativa
            RotativaConfiguration.Setup(env2, "Rotativa");

Alters:

   [Obsolete]
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env, Microsoft.AspNetCore.Hosting.IHostingEnvironment env2)

That solves the problem

Browser other questions tagged

You are not signed in. Login or sign up in order to post.