2

I'm using the Kendo UI dataviz ASP.NET MVC framework for rendering charts, like the example given here (using the ASP.NET MVC version).

The graphs and the series lables renders fine in the browser:

Browser snapshot

For generating the PDF, I use the Rotativa framework - using the wkhtmltopdf tool to convert html content to PDF.

The graph renders perfectly in the PDF, however the series lables on the top is rendered incorrectly:

PDF snapshot

As you can see, there is plenty of room for the labels to span out - but they are being rendered "randomly" on top of each other.

I have multiple graphs in the same exported PDF, and the all the labels for all the charts are incorrectly placed.

Here is my rotativa action result settings:

return new ViewAsPdf("Reports/_ReportBaseIndex", FilterData)
    {
        PageOrientation = ExportOrientation,
        CustomSwitches = "--disable-smart-shrinking --print-media-type --zoom 0.75 --javascript-delay 1000"
    };

Is there any way to fix the lables? Is it possible to statically place the labels, or do I have to recalculate the label positions? If so, how do I do that?

JAM
  • 6,045
  • 1
  • 32
  • 48
  • did you ever find a solution for this? I can't even get my graphs to generate properly Rotativa .. they look squashed and only draw half the graphs.. how did you managed to get it all drawn? – user2206329 Dec 13 '13 at 05:22
  • @user2206329 not resolved yet :( still working on it. – JAM Dec 16 '13 at 01:02
  • JAM - I managed to fix the issue with the squashed and half drawn graphs... – user2206329 Dec 16 '13 at 02:34
  • @user2206329 Yes, I belive thats due to any animation set to render the graph. Thats either solved by disabling the animations, or setting a `--javascript-delay`. – JAM Dec 16 '13 at 09:32

2 Answers2

0

Our solution was to replace the PDF generator to Evo Pdf.

This fixed all of the rendering problems for us.

JAM
  • 6,045
  • 1
  • 32
  • 48
0

I'm also having this issue. Looks like it's related to wkhtmltopdf rather than rotativa. Rotativa actually uses this under the hood anyway.

I've tried generating the PDF both with Rotativa and wkhtmltopdf and get the issue using both.

The solution I went for was to generate the legend manually in the view, looping through the different categories and colours like so

        <table class="legend-table">
    @foreach (var category in Model.Data)
    { 
        <tr>
            <td style="background-color: @category.Colour"></td>
            <td>@category.Category</td>
            <td>@category.Value %</td>
        </tr>
    }
</table>
RTL
  • 16
  • I see, but that is extra work. It should work out of the box, and it does with Evo Pdf :) – JAM Jan 06 '15 at 09:13