執行自訂 JavaScript
使用 IronPDF,透過 JavaScript 程式碼輕鬆修改 HTML 內容外觀。 IronPDF 是 Iron Software 產品庫的一部分,以其強大的 HTML 轉 PDF 功能而聞名,同時也支援 JavaScript、CSS 等。
要實現這一點,首先要定義 JavaScript 程式碼。 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.
最後,將產生的 PDF 檔案(其中包含了執行的 JavaScript 程式碼的效果,即文字顏色變為紅色)儲存為"executed_js.pdf"。
要了解有關 IronPDF 或其他 Iron Software 庫(如IronBarcode 、 IronOCR等)的功能的更多信息,請訪問 Iron Software官方網站。




