Hey,
I tried to create a PDF report from a Plotly graph using pdfkit and wkhtmltopdf with the following code:
import plotly.offline as offline
import plotly.graph_objs as go
import pdfkit
data = [go.Bar(x=[2, 4, 6], y=[10, 12, 15])]
layout = go.Layout(title='A Simple Plot', width=800, height=640)
fig = offline.plot({'data': data,
'layout': layout},
auto_open=False,
show_link=False,
output_type='div', include_plotlyjs=True)
opt = {'javascript-delay': 1000,
'no-stop-slow-scripts': None,
'debug-javascript': None}
pdfkit.from_string(fig, 'test.pdf', options=opt)
when I use Linux, everything works like a charm. But on windows, the generated PDF is always empty and wkhtmltopdf throws a Javascript Error:
Loading pages (1/6)
Warning: undefined:0 TypeError: 'undefined' is not a function
Warning: undefined:0 ReferenceError: Can't find variable: Plotly
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Any ideas why? Or is there another solution for pdf report generation with plotly (offline)?
Best