Problems generating a PDF View using Rotary

Asked

Viewed 313 times

0

I’m trying to learn how to convert a View to PDF format so it can be printed or downloaded by a user.

I read some posts and decided to follow the indication of a library called Rotating that seemed very simple to use.

It actually generated a PDF, but the generated PDF came with my application Login page, instead of the View that was passed to Action.

I think it has something to do with access rights. I tried to put a [Allowanonymous] on Action but that didn’t change the result.

Controller code is simple and was done following the guidelines on the Rotary page:

[AllowAnonymous]
    public ActionResult CriarRelatorioEmPDF(FiltroDeTarefaHorasViewModel model)
    {
        model = CarregarModelo(model);

        return new ActionAsPdf("RelatorioEmPDF", model ) { FileName = "RelatorioDeHoras.pdf" };            
    }

    public ActionResult RelatorioEmPDF(FiltroDeTarefaHorasViewModel model)
    {
        return View(model);
    }

Any idea what might be going on and how to solve it?

Thanks in advance.

  • How are you calling the Action?

  • I called for an Actionlink:@Html.Actionlink("Generate PDF", "Create Reportempdf", Model, new { @class = "glyphicon glyphicon-print" }) and checked, is receiving the model with all its values.

No answers

Browser other questions tagged

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