IronPDF 操作指南 填写和编辑 PDF 表单 How to Fill and Edit PDF Forms Chaknith Bin 已更新:八月 20, 2025 Download IronPDF NuGet 下载 DLL 下载 Windows 安装程序 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English role="alert"> 您的企业在PDF安全性和合规性的年度订阅上花费过多。考虑使用IronSecureDoc,它提供数字签名、涂黑、加密和保护等SaaS服务管理的解决方案,仅需一次性付费。探索IronSecureDoc文档 IronPDF 提供了一组直观的工具,可以编辑 PDF 文档中的现有表单,包括文本区域、文本输入、复选框、组合框和单选按钮。 快速入门:使用 IronPDF 填写 PDF 表单 只需几个步骤,便可轻松使用 IronPDF 填写和编辑 PDF 表单。 本快速指南演示如何定位表单字段、修改其值并保存更新后的文档。 非常适合希望将 PDF 表单编辑功能无缝集成到其 C# 应用程序中的开发人员。 Get started making PDFs with NuGet now: Install IronPDF with NuGet Package Manager PM > Install-Package IronPdf Copy and run this code snippet. var pdf = IronPdf.PdfDocument.FromFile("form.pdf"); var field = pdf.Form.FindFormField("nameField"); field.Value = "John Doe"; pdf.SaveAs("updated_form.pdf"); Deploy to test on your live environment Start using IronPDF in your project today with a free trial Free 30 day Trial class="hsg-featured-snippet"> 最小工作流程(5 步骤) 下载用于填写和编辑 PDF 表单的 C# 库 使用 FromFile 方法导入目标 PDF 文档 使用 FindFormField 方法找到要修改的表单对象 修改 Value 属性以设置所需信息 导出编辑后的 PDF 文档 编辑表单 IronPDF 无缝编辑 PDF 文档中各种类型的现有表单字段。 文本区域和输入表单 要编辑文本区域和输入表单,将 Value 属性分配为所需信息。 以下代码首先使用表单名称通过 FindFormField 方法找到表单对象。 然后,它访问并分配对象的 Value 属性。 :path=/static-assets/pdf/content-code-examples/how-to/edit-forms-input-textarea.cs using IronPdf; PdfDocument pdf = PdfDocument.FromFile("textAreaAndInputForm.pdf"); // Set text input form values pdf.Form.FindFormField("firstname").Value = "John"; pdf.Form.FindFormField("lastname").Value = "Smith"; // Set text area form values pdf.Form.FindFormField("address").Value = "Iron Software LLC\r\n205 N. Michigan Ave."; pdf.SaveAs("textAreaAndInputFormEdited.pdf"); Imports Microsoft.VisualBasic Imports IronPdf Private pdf As PdfDocument = PdfDocument.FromFile("textAreaAndInputForm.pdf") ' Set text input form values pdf.Form.FindFormField("firstname").Value = "John" pdf.Form.FindFormField("lastname").Value = "Smith" ' Set text area form values pdf.Form.FindFormField("address").Value = "Iron Software LLC" & vbCrLf & "205 N. Michigan Ave." pdf.SaveAs("textAreaAndInputFormEdited.pdf") $vbLabelText $csharpLabel 输出 PDF 文档 复选框和组合框表单 编辑现有的复选框和组合框表单时,首先按名称找到表单字段。 将 Value 属性分配为 'Yes' 以勾选复选框表单。 通过将所需选择分配给其 Value 属性,选择组合框中的任何可用选择。 为方便起见,通过访问 Choices 属性检索所有选择值。 :path=/static-assets/pdf/content-code-examples/how-to/edit-forms-checkbox-combobox.cs using IronPdf; using System; PdfDocument pdf = PdfDocument.FromFile("checkboxAndComboboxForm.pdf"); var checkboxForm = pdf.Form.FindFormField("taskCompleted"); // Check the checkbox form checkboxForm.Value = "Yes"; var comboboxForm = pdf.Form.FindFormField("priority"); // Set the combobox value comboboxForm.Value = "Low"; // Print out all the available choices foreach (var choice in comboboxForm.Choices) { Console.WriteLine(choice); } pdf.SaveAs("checkboxAndComboboxFormEdited.pdf"); Imports IronPdf Imports System Private pdf As PdfDocument = PdfDocument.FromFile("checkboxAndComboboxForm.pdf") Private checkboxForm = pdf.Form.FindFormField("taskCompleted") ' Check the checkbox form checkboxForm.Value = "Yes" Dim comboboxForm = pdf.Form.FindFormField("priority") ' Set the combobox value comboboxForm.Value = "Low" ' Print out all the available choices For Each choice In comboboxForm.Choices Console.WriteLine(choice) Next choice pdf.SaveAs("checkboxAndComboboxFormEdited.pdf") $vbLabelText $csharpLabel 输出 PDF 文档 单选按钮表单 在IronPDF处理中使用单选按钮表单时,同一组的单选按钮包含在一个表单对象中。 要编辑单选按钮的值,只需将表单对象的 Value 属性分配为可用的选择之一。 使用 Annotations 属性检索所有可用选择。 以下代码演示如何编辑单选按钮的值。 :path=/static-assets/pdf/content-code-examples/how-to/edit-forms-radiobutton.cs using IronPdf; using System; PdfDocument pdf = PdfDocument.FromFile("radioButtomForm.pdf"); var radioForm = pdf.Form.FindFormField("traveltype"); // Set the radio button value radioForm.Value = "Airplane"; // Print out all the available choices foreach(var annotation in radioForm.Annotations) { Console.WriteLine(annotation.OnAppearance); } pdf.SaveAs("radioButtomFormEdited.pdf"); Imports IronPdf Imports System Private pdf As PdfDocument = PdfDocument.FromFile("radioButtomForm.pdf") Private radioForm = pdf.Form.FindFormField("traveltype") ' Set the radio button value radioForm.Value = "Airplane" ' Print out all the available choices For Each annotation In radioForm.Annotations Console.WriteLine(annotation.OnAppearance) Next annotation pdf.SaveAs("radioButtomFormEdited.pdf") $vbLabelText $csharpLabel 此外,使用 Clear 方法取消选择单选按钮。 只有当对象类型为 RadioFormField 时,才能访问此方法。 从 PDF 访问单选表单对象后,可以将其转换为 RadioFormField 类型。 输出 PDF 文档 <hr 移除表单 要从 PDF 中移除表单,首先使用 FindFormField 方法选择目标表单。 将表单对象传递给 PdfDocument 对象的 Form.Remove 方法。 :path=/static-assets/pdf/content-code-examples/how-to/edit-forms-remove-form.cs using IronPdf; using IronSoftware.Forms; PdfDocument pdf = PdfDocument.FromFile("textAreaAndInputForm.pdf"); // Remove Form IFormField targetForm = pdf.Form.FindFormField("firstname"); pdf.Form.Remove(targetForm); pdf.SaveAs("removedForm.pdf"); Imports IronPdf Imports IronSoftware.Forms Private pdf As PdfDocument = PdfDocument.FromFile("textAreaAndInputForm.pdf") ' Remove Form Private targetForm As IFormField = pdf.Form.FindFormField("firstname") pdf.Form.Remove(targetForm) pdf.SaveAs("removedForm.pdf") $vbLabelText $csharpLabel 输出 PDF 文档 在以下文章中了解如何通过编程方式创建 PDF 表单:"如何创建 PDF 表单。" 准备好看看您还能做些什么吗? 查看我们的教程页面:签名和保护PDFs 常见问题解答 如何使用 C# 库开始编辑 PDF 表单? 要开始使用 IronPDF 编辑 PDF 表单,首先从 NuGet 下载 C# 库。然后,使用 FromFile 方法导入 PDF 文档,使用 FindFormField 定位表单字段,并根据需要修改 Value 属性。 如何在 PDF 中使用 C# 库编辑文本区域和输入表单? 要编辑文本区域和输入表单,请使用 FindFormField 方法按名称定位表单字段。然后,将所需值分配给 IronPDF 中表单字段对象的 Value 属性。 如何使用 C# 库在 PDF 表单中编辑复选框和组合框? 要编辑复选框,将 Value 属性设置为 'Yes'。对于组合框,找到字段后,通过 FindFormField 分配所需选项到 Value 属性。您可以使用 IronPDF 中的 Choices 属性访问所有选项值。 使用 C# 库编辑单选按钮表单的方法是什么? 通过将所需选项分配给 IronPDF 中表单对象的 Value 属性来编辑单选按钮。使用 Annotations 属性访问所有可用选项,并使用 Clear 方法取消选择单选按钮。 如何使用 C# 库从 PDF 中移除表单? 要从 PDF 中移除表单,请使用 FindFormField 方法选择表单字段,然后将字段对象传递给 IronPDF 中 PdfDocument 对象的 Form.Remove 方法。 可以使用 C# 库编辑任何类型的现有 PDF 表单字段吗? 是的,IronPDF 可以编辑 PDF 文档中现有的表单字段,如文本区域、文本输入、复选框、组合框和单选按钮。 是否可以使用 C# 库以编程方式创建 PDF 表单? 是的,您可以使用 IronPDF 以编程方式创建 PDF 表单。有关更多信息,请参阅文章 '[How to Create PDF Forms](/how-to/create-forms/)'。 文档管理解决方案提供哪些附加功能? IronSecureDoc 提供用于管理 SaaS 服务的解决方案,如数字签名、修订、加密和保护,全部一次性付款。 在使用 C# 修改表单字段后,如何导出编辑后的 PDF? 在使用 IronPDF 修改表单字段后,可以通过在 PdfDocument 对象上使用 SaveAs 方法将更改保存回文件系统,导出编辑后的 PDF 文档。 我可以使用 C# 访问和编辑 PDF 组合框中的所有选项吗? 是的,使用 IronPDF,您可以通过 Choices 属性访问 PDF 组合框中的所有选项,并通过设置 Value 属性编辑所需选项。 .NET 10 兼容性:我可以使用 IronPDF 编辑面向 .NET 10 的 PDF 表单吗? 是的——IronPDF 与 .NET 10 完全兼容,因此您可以在 .NET 10 项目中使用相同的 API(如FindFormField 、 Form和PdfDocument )编辑 PDF 表单(包括查找、更改和删除表单字段),而无需任何特殊的代码更改。 Chaknith Bin 立即与工程团队聊天 软件工程师 Chaknith 在 IronXL 和 IronBarcode 工作。他在 C# 和 .NET 方面有着深厚的专业知识,帮助改进软件并支持客户。他从用户互动中获得的见解有助于更好的产品、文档和整体体验。 准备开始了吗? Nuget 下载 16,154,058 | 版本: 2025.11 刚刚发布 免费 NuGet 下载 总下载量:16,154,058 查看许可证