from ironpdf import * html_with_javascript = """ <h1>This is HTML</h1> <script> document.write('<h1>This is JavaScript</h1>'); </script> """ # Instantiate Renderer renderer = ChromePdfRenderer() # Enable JavaScript in our RenderingOptions renderer.RenderingOptions.EnableJavaScript = True renderer.RenderingOptions.WaitFor.RenderDelay(100) pdf_javascript = renderer.RenderHtmlAsPdf(html_with_javascript) # Export to a file or Stream pdf_javascript.SaveAs("javascript-in-html.pdf")
在 HTML 中將 JavaScript 轉換為 PDF