可通过 Python 填写的 PDF 表单

通过 Python 创建可填写的 PDF 表单。使用服务器端 API 构建自己的 Python for .NET 应用程序

如何使用 Python for .NET 库填写 PDF 表单

为了在 PDF 文件中填写 PDF 表单 (Acroforms),我们将使用 Aspose.PDF for .NET API,这是适用于 python-net 平台的功能丰富、强大且易于使用的文档操作 API。你可以直接从 NuGet 包管理器下载其最新版本,搜索aspose.pdf然后安装。您也可以使用包管理器控制台中的以下命令。

如何使用 Python 在 PDF 中填写 AcroForm


你需要 Aspose.PDF for .NET 才能在你的环境中试用代码。

1.在 “文档” 类的实例中加载 PDF。 1.在 PDF 文件中创建字段。 1.向文档中添加字段。 1.保存修改过的 PDF

在 PDF 中填写 AcroForm-Python

此示例代码显示如何使用 Python 在 PDF 中填写 PDF 表单

    // Step 1. Open document
    Document pdfDocument = new Document(dataDir + "FillFormField.pdf");

    // Step 2. Get a field
    TextBoxField textBoxField = pdfDocument.Form["textbox1"] as TextBoxField;

    // Step 3. Modify field value
    textBoxField.Value = "Value to be filled in the field";
    dataDir = dataDir + "FillFormField_out.pdf";

    // Step 4. Save updated document
    pdfDocument.Save(dataDir);