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 フォームを定義する必要があります。 これらのフォーム要素により、ユーザーはデータを入力し、選択を行うことができます。

これを実現するために createPdfFormsFromHtml オプションを 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.11リリースされたばかり