IRONSOFTWAREHOME
PDFフォーム
using IronPdf;
using System;

// Step 1.  Creating a PDF with editable forms from HTML using form and input tags
// Radio Button and Checkbox can also be implemented with input type 'radio' and 'checkbox'
const string 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>";

// Instantiate Renderer
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
renderer.RenderHtmlAsPdf(formHtml).SaveAs("BasicForm.pdf");

// Step 2. Reading and Writing PDF form values.
var FormDocument = PdfDocument.FromFile("BasicForm.pdf");

// Set and Read the value of the "firstname" field
var FirstNameField = FormDocument.Form.FindFormField("firstname");
FirstNameField.Value = "Minnie";
Console.WriteLine("FirstNameField value: {0}", FirstNameField.Value);

// Set and Read the value of the "lastname" field
var LastNameField = FormDocument.Form.FindFormField("lastname");
LastNameField.Value = "Mouse";
Console.WriteLine("LastNameField value: {0}", LastNameField.Value);

FormDocument.SaveAs("FilledForm.pdf");
Imports IronPdf
Imports System

' Step 1.  Creating a PDF with editable forms from HTML using form and input tags
' Radio Button and Checkbox can also be implemented with input type 'radio' and 'checkbox'
Const formHtml As String = "
    <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>"

' Instantiate Renderer
Dim renderer = New ChromePdfRenderer()
renderer.RenderingOptions.CreatePdfFormsFromHtml = True
renderer.RenderHtmlAsPdf(formHtml).SaveAs("BasicForm.pdf")

' Step 2. Reading and Writing PDF form values.
Dim FormDocument = PdfDocument.FromFile("BasicForm.pdf")

' Set and Read the value of the "firstname" field
Dim FirstNameField = FormDocument.Form.FindFormField("firstname")
FirstNameField.Value = "Minnie"
Console.WriteLine("FirstNameField value: {0}", FirstNameField.Value)

' Set and Read the value of the "lastname" field
Dim LastNameField = FormDocument.Form.FindFormField("lastname")
LastNameField.Value = "Mouse"
Console.WriteLine("LastNameField value: {0}", LastNameField.Value)

FormDocument.SaveAs("FilledForm.pdf")
NuGet Download
PM > Install-Package IronPdf
PDFフォーム

PDFフォーム

IronPDFを使用して、通常のドキュメントと同様に編集可能なPDFドキュメントを作成できます。 PdfForm クラスは、PDFドキュメント内のユーザー編集可能なフォームフィールドの集合です。 それはPDFレンダーに実装され、フォームまたは編集可能なドキュメントにすることができます。

この例では、IronPDFで編集可能なPDFフォームを作成する方法を示しています。

編集可能なフォームを持つPDFは、ドキュメントの部分に<textarea> タグを追加するだけでHTMLから作成できます。

PdfDocument.Form.FindFormField メソッドは、任意のフォームフィールドの値を読み書きするために使用できます。 フィールドの name 属性は、HTML内でそのフィールドに付与されます。

PdfDocument.Form オブジェクトは、二つの方法で使用できます。

  • デフォルト値の設定: これはAdobe ReaderのようなPDFビューアで表示されるフォームフィールドのデフォルト値を設定するために使用されます。
  • ユーザー入力の読み取り: ユーザーがフォームに入力した後、フォームフィールドにアクセスしてデータをアプリケーションに戻すことができます。

上記の例では、最初にIronPdf ライブラリをインポートし、CreateEditablePdfDocument メソッドを定義します。 このメソッドには、ユーザー名とコメントの入力フィールドを持つシンプルなフォームのHTML構造が含まれています。 HtmlToPdf レンダラーを使用して、このHTMLコンテンツをPDFドキュメントに変換します。

その後、pdfDocument.Form を使用してフォームフィールドにアクセスし、操作します。 PDFビューアでドキュメントを開くと表示されるデフォルト値を設定します。 最後に、"EditableForm.pdf"という名前でドキュメントを保存し、埋め込み編集可能フィールドを持つドキュメントを保存または共有できるようにします。

IronPDF ハウツーガイドでPDFフォームの編集を学ぶ
GitHubで見る

準備はできましたか?

Nuget Downloads 21,105,021バージョン:2026.9リリースされたばかり

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

世界中の数百万人のエンジニアから信頼されています。

ライセンスはより安く
義務のない相談を受ける
下記のフォームを記入するか、sales@ironsoftware.comにメールしてください。
あなたの詳細は常に守秘されます。
世界中の数百万人のエンジニアから信頼されています。
ライセンスはより安く
あなたの無料30日間の試用キーをすぐに入手。
クレジットカードやアカウントの作成は不要です。
PDF用C# NuGetライブラリ
NuGetでインストール

バージョン: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. ソリューションエクスプローラーで参照を右クリックし、NuGetパッケージを管理を選択
  2. ブラウズを選択し、"IronPDF"を検索
  3. パッケージを選択してインストール
C# PDF DLL
DLLをダウンロード

バージョン: 2026.9

またはここからWindowsインストーラーをダウンロードする。

  1. IronPDFを~/Libsなどの場所に解凍し、ソリューションディレクトリ内に配置する
  2. Visual Studioソリューションエクスプローラーで参照を右クリックし、"IronPDF.dll"をブラウズして選択

ライセンスは$999から