from ironpdf import * # Instantiate Renderer renderer = ChromePdfRenderer() # Example that change all to red style in JavaScript: renderer.RenderingOptions.Javascript = "document.querySelectorAll('h1').forEach(function(el){el.style.color='red';})" # Make sure to use the render options object that you created: pdf = renderer.RenderHtmlAsPdf("<h1>Happy New Year!</h1>") pdf.SaveAs("executed_js.pdf")
执行自定义JavaScript