Cannot print Asp.net MVC 5.2.2 view in Rotativa.MV

2019-07-22 15:23发布

问题:

I have a Asp.net MVC 5.2.2 web application where i have Rotativa.MVC 2.0.3 installed via nuget package. I am using Visual Studio Community 2013 Update 4 on Windows 8.1 Pro 64-bit/8GB Ram.

My view displays data from SQL Server Database and in addition to that it also displays some data in graphs using amcharts 3.13.3.

I get the following error when i call the action from the view:

[Exception: QFont::setPixelSize: Pixel size <= 0 (0) QFont::setPixelSize: Pixel size <= 0 (0) QFont::setPixelSize: Pixel size <= 0 (0)

When i add CustomSwitches = "--grayscale" it works because it prints it in black/white but I need it to work with color.

Below is the action i am calling from the view:

    public ActionResult PrintSummary()
    {
        string fileName = "PrintSummary_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf";
        var rotativaOptions = new Rotativa.Core.DriverOptions() { CustomSwitches = "" };
        return new ActionAsPdf("Print", new { fromPrintpdf = "numbers i pass in"})
        {
            FileName = fileName,
            RotativaOptions = rotativaOptions
        };
    }