webgio / Rotativa

Rotativa, /rota'tiva/. Make Pdf from Asp.Net MVC. Available on Nuget https://www.nuget.org/packages/Rotativa
http://letsfollowtheyellowbrickroad.blogspot.it/search/label/Rotativa
MIT License
621 stars 224 forks source link

ViewAsPdf not show Chat javascript PDF #219

Open ivanteles opened 4 years ago

ivanteles commented 4 years ago

My action

return new ViewAsPdf()
            {                
                CustomSwitches = "--enable-javascript --debug-javascript --no-stop-slow-scripts --javascript-delay 10000",
                IsJavaScriptDisabled = false,
                FileName = $"grafico_{id}_{dataInicial}_{dataFinal}.pdf",
                PageSize = Size.A4,
                PageOrientation = Orientation.Landscape,
                PageMargins = { Left = 0, Right = 0 },
                ContentDisposition = ContentDisposition.Inline
            };

MyView

<canvas id="myChart" height="150"></canvas>
 <script src="http://localhost:11180/Content/chartJs/Chart.min.js"></script>
@section scripts{
            <script>
                var ctx = document.getElementById("myChart").getContext("2d");
                let chart = new Chart(ctx,
                    {
                        type: 'line',
                        data: @Html.Raw(ViewBag.data),
                        options: {
                            scales: {
                                yAxes: [
                                    {
                                        ticks: {
                                            suggestedMin: 0,
                                            suggestedMax: 10
                                        }
                                    }
                                ]
                            }
                        }, scales: {
                            yAxes: [{
                                type: 'linear', // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance
                                display: true,
                                position: 'left',
                                id: 'y-axis-1'
                            }, {
                                type: 'linear', // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance
                                display: true,
                                position: 'right',
                                id: 'y-axis-2',

                                gridLines: {
                                    drawOnChartArea: false, // only want the grid lines for one axis to show up
                                }
                            }]
                        }
                    });
            </script>
        }
gdaguilarc commented 4 years ago

Same Issue

I have the same issue and I implement the same "CustomSwitches" even with more delay time. The only diference is I am using AMCharts, I do not know if it has support to them. 🆘

gurneetsinghb commented 3 years ago

I didn't completely understand this issue but I've recently faced the issue where the code in my script tag was not working at all and it was due to the 'let' keyword. When I changed the 'let' to 'var' the issue was resolved. I just noticed the 'let' keyword in the code above and thought that my answer might help. 😃