Execute Custom JavaScript
Effortlessly modify HTML content appearance with JavaScript code using IronPDF. IronPDF is a part of Iron Software's product libraries, known for its robust capabilities in converting HTML to PDF while supporting JavaScript, CSS, and more.
To achieve this, start by defining the JavaScript code. In our example, we'll change the text color of all H1 tags to red.
Next, create a rendering options object and set the enableJavaScript
property to true. Assign the previously defined JavaScript code to the javascript
property within this object.
Utilize the PdfDocument.fromHtml
method to render the HTML content into a PDF document. Pass the renderOptions
object as the second parameter.
Finally, save the resulting PDF, which incorporates the effects of the executed JavaScript code (changing text color to red), as 'executed_js.pdf'.
To learn more about the capabilities of IronPDF or other Iron Software libraries such as IronBarcode, IronOCR, and more, visit the Iron Software official website.