IRONSOFTWAREHOME
PDF 表單
import {PdfDocument} from "@ironsoftware/ironpdf";

(async () => {
    // Define the HTML content with editable form fields
    const formHtml = `
        <html>
            <body>
                <h2>Editable PDF Form</h2>
                <form>
                    First name: <br> <input type='text' name='firstname' value=''> <br>
                    Last name: <br> <input type='text' name='lastname' value=''> <br>
                    <br>
                    <p>Please specify your gender:</p>
                    <input type='radio' id='female' name='gender' value='Female'>
                    <label for='female'>Female</label> <br>
                    <br>
                    <input type='radio' id='male' name='gender' value='Male'>
                    <label for='male'>Male</label> <br>
                    <br>
                    <input type='radio' id='non-binary/other' name='gender' value='Non-Binary / Other'>
                    <label for='non-binary/other'>Non-Binary / Other</label>
                    <br>
                    <p>Please select all medical conditions that apply:</p>
                    <input type='checkbox' id='condition1' name='Hypertension' value='Hypertension'>
                    <label for='condition1'> Hypertension</label><br>
                    <input type='checkbox' id='condition2' name='Heart Disease' value='Heart Disease'>
                    <label for='condition2'> Heart Disease</label><br>
                    <input type='checkbox' id='condition3' name='Stoke' value='Stoke'>
                    <label for='condition3'> Stoke</label><br>
                    <input type='checkbox' id='condition4' name='Diabetes' value='Diabetes'>
                    <label for='condition4'> Diabetes</label><br>
                    <input type='checkbox' id='condition5' name='Kidney Disease' value='Kidney Disease'>
                    <label for='condition5'> Kidney Disease</label><br>
                </form>
            </body>
        </html>
    `;

    // Configure render options
    const options = {
        createPdfFormsFromHtml: true,
    };

    // Render HTML content to a PDF with editable forms
    const pdf = await PdfDocument.fromHtml(formHtml, { renderOptions: options });

    // Save the new PDF
    await pdf.saveAs("formField.pdf");
})();
npm i @ironsoftware/ironpdf
PDF 表單

PDF 表單

包含表單欄位的HTML也可以渲染成PDF,且保持表單欄位資訊和功能完好無損。 從HTML內容建立可編輯的PDF表單涉及定義含有各種輸入欄位(如文字欄位、單選按鈕和核取方塊)的HTML表單。 這些表單元素允許使用者輸入資料並進行選擇。

為了實現這一點,將true。 此選項指定HTML表單應轉換成可編輯的PDF表單。

接下來,使用PdfDocument.fromHtml方法將HTML內容渲染到PDF文件中。 將指定的渲染選項作為物件參數傳遞。

最後,使用saveAs方法將可編輯表單欄位PDF匯出為名為"formField.pdf"的新PDF文件。

要了解有關從HTML內容生成PDF表單的更多資訊,請存取IronPDF產品頁面以獲取詳細資訊和範例。

<a href="https://github.com/iron-software/IronPdfNode.Examples/tree/main/examples/form-data" class="code_content__related-link__doc-cta-link">Explore Code Examples for Creating PDF Forms from HTML</a>
HTML
在 GitHub 上查看

準備好開始了嗎?

版本:2026.6剛剛發布

Key in blue circle

立即免費取得 30 天試用金鑰。

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

OR
bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
預訂您的免費線上演示
Booking Badge

獲得來自全球數百萬工程師的信賴

Iron Software的客戶徽標
獲取您的無義務諮詢
填寫以下表格或發送電子郵件至sales@ironsoftware.com
您的資料將始終保密。
獲得來自全球數百萬工程師的信賴
Iron Software的客戶徽標
立即獲取您的30天試用金鑰。
無需信用卡或帳戶建立
Node.js模組下載PDF
使用npm安裝

版本: 2026.6

  1. 下載並安裝Node.js 12+。
  2. 在終端機中執行上述命令。

授權從$999起