Rotativa icon indicating copy to clipboard operation
Rotativa copied to clipboard

ActionAsPdf Hangs

Open southplatte opened this issue 10 years ago • 4 comments

Working with Rotativa 1.6.4 from NuGet on MVC 5 application. Works great except for when using ActionAsPdf to get the binary to attach to email.

        var pdfResult = new ActionAsPdf("Report", new {id = Request.Params["id"]})
        {
            Cookies = cookieCollection,
            FormsAuthenticationCookieName = FormsAuthentication.FormsCookieName,
            CustomSwitches = "--load-error-handling ignore"
        };

        var binary = pdfResult.BuildPdf(this.ControllerContext);

The issue happens on the pdfResult = new ActionAsPdf() just hangs randomly before it actually enters into the "Report" action. Having done step debugging there is a definitely delay from hitting the line referenced and before it enters into the Report() action being called.

Seems random as sometimes it works without delay and sometimes the delay can vary from 10 seconds up to 3-4 minutes.

No other PDF action in use has any issues in this project and the Report action can be called directly by way of http://mysite.com/Report without any delay whatsoever.

southplatte avatar Sep 29 '15 20:09 southplatte

Good Morning,

I'm having the same issue - in my case the delay is around 2-4 minutes, for a 4-6 page PDF.

I'm also using MVC 5, and I don't have a problem when the action is not authorised (i.e. <AllowAnonymous>) and therefore cookies not required. The delay only occurs when cookies are set in the options, and then BuildPDF is called to create the binary.

Thanks for a great application otherwise!

Simon

paddysimon avatar Jan 14 '16 09:01 paddysimon

I've hit the same issue as well, using ActionAsPdf() (with cookies for authorisation), however using the newer style ViewAsPdf() syntax works without any delays. This is with MVC 4 trying to generate a two page PDF.

thecodefish avatar Mar 09 '16 02:03 thecodefish

Beta version 1.7.1 using BuildFile still displays this same issue. As soon as BuildFile is called, it will just sit and spin for about 2-3 minutes before continuing to the next line of code.

Authorized methods only. Decorating the action with [AllowAnonymous], in and of itself did not fix the issue.

Removing these options on the ActionAsPdf b = new ActionAsPdf(){ Cookies = cookieCollection, FormsAuthenticationCookieName = FormsAuthentication.FormsCookieName }

call, however, did fix the slow issue.

southplatte avatar Jul 01 '16 00:07 southplatte

Same issue here on 1.7.2:

var cookies = Request.Cookies.AllKeys.ToDictionary(k => k, k => Request.Cookies[k].Value);
return new Rotativa.ActionAsPdf("Details", new { id = id, pdf = "1" })
{
    FileName = obj.Name + " [awesomeness].pdf",
    FormsAuthenticationCookieName = System.Web.Security.FormsAuthentication.FormsCookieName,
    Cookies = cookies,
    PageMargins = new Rotativa.Options.Margins { Left = 0, Right = 0, Top = 0, Bottom = 0 }
};

karlingen avatar Oct 16 '17 07:10 karlingen