可通过 C++ 填写的 PDF 表单

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

如何使用 C++ 库填写 PDF 表单

为了在 PDF 文件中填写 PDF 表单 (Acroforms),我们将使用 Aspose.PDF for C++ API,这是适用于 cpp 平台的功能丰富、强大且易于使用的文档操作 API。打开 NuGet 包管理器,搜索aspose.pdf然后安装。您也可以使用包管理器控制台中的以下命令。

如何使用 C++ 在 PDF 中填写 AcroForm


您需要為[Aspose.PDF for C++]https://releases.aspose.com/pdf/cpp) 才能在您的環境中嘗試代碼。

  1. 在文件類的實例中載入 PDF。
  2. 在 PDF 檔案中建立一個字段。
  3. 向文件添加欄位。
  4. 保存修改後的 PDF

在 PDF 中填写 AcroForm-C++

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

    String _dataDir("C:\\Samples\\");

    // Open document
    auto document = MakeObject<Document>(_dataDir + u"FillFormField.pdf");

    // Get a field
    auto textBoxField = System::DynamicCast<Aspose::Pdf::Forms::TextBoxField>(document->get_Form()->idx_get(u"textbox1"));

    // Modify field value
    textBoxField->set_Value(u"Value to be filled in the field");

    // Save updated document
    document->Save(_dataDir + u"FillFormField_out.pdf");