執行自訂 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庫(如IronBarcodeIronOCR等)的功能的更多信息,請訪問Iron Software官方網站

立即探索執行自訂JavaScript程式碼範例!

準備好開始了嗎?
版本: 2026.3 剛剛發布
Still Scrolling Icon

還在捲動嗎?

想要快速證明?
執行範例 觀看您的 HTML 變成 PDF。