Debugging javascript in wkhtmltopdf

后端 未结 3 553
没有蜡笔的小新
没有蜡笔的小新 2021-01-01 13:57

Where I can see the output of javascript debug when wkhtmltopdf runs in debug mode (--debug-javascript)

3条回答
  •  猫巷女王i
    2021-01-01 14:46

    Although Daffy Punks answer is correct, I had an additional idea some weeks ago, that helped me a lot. This I want to share: Show it inside PDF

    When rendering the layout for PDF I put an additional (hidden) DIV #pdf_errors

    And very early in source - if #pdf_errors is here - I let point console output to fill this div, and on error - I show it. Its not really debugging, but at least I see now what was going wrong.

    Source in coffeescript, my plain javascript times are long gone ...

    if ($pdf=$("#pdf_is_here")).length
        for type in ["log","warn","error"]
            do (type) =>
                console[type]= (a...) =>
                    $pdf.append("
    #{s}
    ") for s in a window.onerror= (messageOrEvent, source, lineno, colno, error) => $pdf.append("
    #{messageOrEvent}
    ") $pdf.show() $pdf.hide() # just in case css is not here

提交回复
热议问题