incuna / django-wkhtmltopdf

Django Wrapper to the PDF Renderer: wkhtmltopdf
BSD 2-Clause "Simplified" License
325 stars 155 forks source link

Not rendering d3 charts. #153

Open mkok1019 opened 7 years ago

mkok1019 commented 7 years ago

I am going to render d3 charts into PDF but it doesn't work.

Actually, I've tested that javascript is running for PDF export, but it doesn't support async callback.

I've described here how it doesn't work on my side.

d3.queue()
    .defer(d3.json, "https://s3.amazonaws.com/xxx.json")
    .defer(d3.json, dataUrl)
    .defer(d3.tsv, "https://s3.amazonaws.com/xxx.tsv")
    .await(ready);

Before this code block, I've confirmed that JS is running correctly. After this code block, I put some JS testing code, but it didn't work and its not coming into PDF.

Can anyone help for this, please?

Freakazo commented 7 years ago

Hey @mkok1019,

Can you try setting

    cmd_options = {
        'javascript-delay': 6000,
    }

The above will wait 6 seconds for the javascript to finish.

Better yet if you can make your javascript emit a string when the page is ready to be captured.

    cmd_options = {
        'javascript-delay': 6000,
        'window-status': 'myrandomstring'
    }

See passing cmd_options and discussion on ajax