Design Interactive Forms with Fillable Fields

# Aspose.Words for .NETを使用して入力可能なフィールドを持つインタラクティブフォームを作成する方法

記入可能なフィールドを備えたインタラクティブなフォームでは、ユーザーがWord ドキュメントに直接データを入力することができます. Aspose.Words for .NET を使用すると、これらのフォームをプログラム的に設計し、調査、アプリケーション、またはデータ収集のためのダイナミックで簡単に配布できます。

原題:Tools for Designing Interactive Forms

  • インストール → ネット SDK あなたのオペレーティングシステム
  • プロジェクトに Aspose.Words を追加する:dotnet add package Aspose.Words
  • Word ドキュメント テンプレートを準備するか、プログラミングで新しいものを作成します。

ステップ・ステップ・インタラクティブ・フォーマット・デザインガイド

ステップ1:新しい単語文書を作成する

using System;
using Aspose.Words;

class Program
{
    static void Main()
    {
        // Create a new document
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);

        // Save the empty document
        doc.Save("InteractiveFormTemplate.docx");
        Console.WriteLine("Blank form template created successfully.");
    }
}

説明: このコードは、新しい白いWordドキュメントを作成し、「InteractiveFormTemplate.docx」として保存します。

ステップ2:フォームに満たすフィールドを追加する

using System;
using Aspose.Words;
using Aspose.Words.Fields;

class Program
{
    static void Main()
    {
        Document doc = new Document("InteractiveFormTemplate.docx");
        DocumentBuilder builder = new DocumentBuilder(doc);

        // Add a text input field
        builder.Writeln("Name:");
        builder.InsertTextInput("NameField", TextFormFieldType.Regular, "", "", 0);

        // Add a dropdown field
        builder.Writeln("Select a department:");
        builder.InsertComboBox("DepartmentField", new[] { "HR", "IT", "Finance" }, 0);

        // Add a checkbox
        builder.Writeln("Agree to Terms:");
        builder.InsertCheckBox("AgreeField", false, 0);

        // Save the form
        doc.Save("InteractiveForm.docx");
        Console.WriteLine("Interactive form created successfully.");
    }
}

説明: このコードは、Word ドキュメントにテキスト入力フィールド、ダウンロードフィールド、チェックボックスを追加し、「InteractiveForm.docx」として保存します。

ステップ3:フォーマットデータをプログラム的に収集および保存

using System;
using Aspose.Words;

class Program
{
    static void Main()
    {
        Document doc = new Document("InteractiveForm.docx");

        // Populate form fields
        doc.Range.FormFields["NameField"].Result = "John Doe";
        doc.Range.FormFields["DepartmentField"].DropDownSelectedIndex = 1; // Select "IT"
        doc.Range.FormFields["AgreeField"].Checked = true;

        // Save the filled form
        doc.Save("FilledInteractiveForm.docx");
        Console.WriteLine("Form fields populated and saved successfully.");
    }
}

説明: このコードは「InteractiveForm.docx」ドキュメントを開き、データを含むフォームフィールドを記録し、「FilledInteractiveForm.docx」として保存します。

ステップ4:配布のためのフォームをPDFに変換する

using System;
using Aspose.Words;

class Program
{
    static void Main()
    {
        Document doc = new Document("FilledInteractiveForm.docx");

        // Save the form as a PDF
        doc.Save("InteractiveForm.pdf", SaveFormat.Pdf);
        Console.WriteLine("Interactive form converted to PDF for distribution.");
    }
}

説明: このコードは「FilledInteractiveForm.docx」ドキュメントを開き、「InteractiveForm.pdf」と呼ばれるPDFファイルに変換します。

インタラクティブな形態のためのリアルワールドアプリケーション

  • レビューとフィードバック:- 迅速なデータ収集のための記入可能なフィールドで調査を配布します。

  • 申請フォーム:- ダウンダウンとテキスト入力で就職申請またはメンバーシップフォームを作成します。

  • 合意:- 条件と条件のチェックボックスを含むデザインフォーム。

インタラクティブな形態の開発シナリオ

  • 企業ポータル:- 内部システム内の形状の作成と配布を自動化する。

  • Webプラットフォーム:- ユーザーの提出のためのWebアプリケーションにフォーム生成を統合します。

共通の問題とインタラクティブな形態の修正

  • サポートされていないフォームフィールド:- 標準フォームフィールド、テキスト、ダウンダウン、およびチェックボックスを使用して互換性を得ることができます。

  • 問題の構成:- プロの外観を確保するために調和とスタイルを調整します。

  • 不完全なデータ人口:- すべてのフィールドがプログラミング的に人口値に正しくマッピングされていることを確認します。

.NET で Aspose.Words を使用してインタラクティブなフォームを設計することで、データ収集を簡素化し、さまざまなワークフローでドキュメントの使用性を向上させることができます。

 日本語