UiPath Documentation
activities
latest
false
重要 :
このコンテンツの一部は機械翻訳によって処理されており、完全な翻訳を保証するものではありません。 新しいコンテンツの翻訳は、およそ 1 ~ 2 週間で公開されます。
UiPath logo, featuring letters U and I in white

Document Understanding アクティビティ

最終更新日時 2026年4月22日

PDF ファイルを読み込み

ドキュメントに含まれるすべての文字を読み取ることのできるアクティビティを使用して、.pdf ファイルの内容を読み取り、個別に抽出できます。

必要に応じて、文字を認識できるシンプルなアクティビティを使用することも、OCR エンジンを持つアクティビティを使用することもできます。OCR エンジンを使用する利点は、スキャンしたドキュメント、署名のあるドキュメント、あるいは手書きのドキュメントであっても、ドキュメントの読み取りを適用できることです。

以下の例は、.pdf ファイルを読み取る 2 つの状況を示しています。

  1. The first one explains how to read the .pdf file while using the Read PDF Text activity.
  2. The second one explains how to read the .pdf file while using the Read PDF With OCR activity. The main difference between the two scenarios is that the second one is also using OCR engines, meaning that the details of extracted information are more accurate than in the first case if the analyzed file is an image, scanned, or includes signed or handwritten fields. You can find both activities in the UiPath.PDF.Activities package.

両方のシナリオに必要なワークフローは 1 つだけであり、任意の読み取り方法の選択をユーザーに求める時点までは共通です。

手順
  1. Studio を開いて、新しいプロセスを作成します。
  2. Add a Flowchart container in the Workflow Designer.
    1. Create a variable named chooseOption, with the GenericValue type, and no default value.
      注:

      同じ場所からプロセス全体を実行できるようにするか、指定されたファイルを使用するためにこの例をダウンロードするには、プロジェクト ディレクトリに .pdf ファイルを追加します。

  3. Add an Input Dialog activity and connect it to the Start Node.
    1. [プロパティ] パネルで、式 "Choose one option below:"[ラベル] フィールドに追加します。
    2. [Options] フィールドに式 {"Read PDF Text", "Read PDF With OCR"} を追加します。
    3. [Title] フィールドに値 "Options" を追加します。
    4. Result (値) フィールドに変数 chooseOption を追加します。
  4. Add a Flow Decision activity after the Input Dialog activity and connect it to it.
    1. [プロパティ] パネルで [Condition] フィールドに式 chooseOption = "Read PDF Text" を追加します。
  5. Add a Sequence container and connect it to the True branch of the Flow Decision activity. The name of the Sequence should be Read PDF Text. This activity extracts information by using regular expressions.
    1. 次の表に示す変数を作成します。

      Table 1. Variables to be created

      変数の型既定値
      extractedText文字列N/A
      arrayTextSystem.String[]N/A
      addressGenericValueN/A
      city文字列N/A
      phoneNumber文字列N/A
      invoiceNumber文字列N/A
      vendorGenericValueN/A
      bankName文字列N/A
      bankAccount文字列N/A
      ibanCode文字列N/A
  6. Add a Sequence container and connect it to the False branch of the Flow Decision activity. The name of the Sequence should be Read PDF With OCR. This activity extracts information by using an OCR engine (Microsoft OCR and Tesseract OCR).
    1. 次の表に示す変数を作成します。

      Table 2. Variables to be created

      変数の型既定値
      extractedTextTesseract文字列N/A
      extractedTextMicrosoft文字列N/A

      Figure 1. Overview of the beginning of the workflow

      ワークフローの始まりの概要

  7. Read a PDF File using the Read PDF Text activity:
    1. Open the Read PDF Text sequence container by double-selecting it.
    2. Add a Read PDF Text activity inside the sequence.
      1. [プロパティ] パネルで [FileName] フィールドに値 "NPO Invoice.pdf" を追加します。
      2. [Range] フィールドに値 "All" を追加します。
      3. [テキスト] フィールドに変数 extractedText を追加します。
  8. Add an Assign activity after the Read PDF Text activity.
    1. [左辺値 (To)/宛先] フィールドに変数 arrayText を追加します。
    2. [右辺値 (Value)] フィールドに式 extractedText.Split(Environment.NewLine.ToArray, StringSplitOptions.RemoveEmptyEntries) を追加します。
  9. [代入] アクティビティの下に [条件分岐 (if)] アクティビティを追加します。
    1. [条件 (Condition)] フィールドに式 arrayText(0).Equals("Tiefland Glass AG") を追加します。
  10. [シーケンス] コンテナー内に [代入] アクティビティを追加します。
    1. [左辺値 (To)/宛先] フィールドに変数 address を追加します。
    2. [右辺値 (Value)] フィールドに式 arrayText(2) を追加します。
  11. Add another Assign activity and place it after the previous one.
    1. [左辺値 (To)/宛先] フィールドに変数 city を追加します。
    2. [右辺値 (Value)] フィールドに式 arrayText(3).Split(","c)(0) を追加します。
  12. Add another Assign activity and place it after the previous one.
    1. [左辺値 (To)/宛先] フィールドに変数 phoneNumber を追加します。
    2. [右辺値 (Value)] フィールドに式 arrayText(4).Split(":"c)(1).Split({"INVOICE"},StringSplitOptions.None)(0) を追加します。
  13. Add another Assign activity and place it after the previous one.
    1. [左辺値 (To)/宛先] フィールドに変数 invoiceNumber を追加します。
    2. [右辺値 (Value)] フィールドに式 arrayText(4).Split(":"c)(1).Split({"INVOICE"},StringSplitOptions.None)(1).Split("#"c)(1) を追加します。
  14. Add another Assign activity and place it after the previous one.
    1. [左辺値 (To)/宛先] フィールドに変数 vendor を追加します。
    2. [右辺値 (Value)] フィールドに式 arrayText(arrayText.Count-5) を追加します。
  15. Add an Assign activity inside the Else field.
    1. [左辺値 (To)/宛先] フィールドに変数 address を追加します。
    2. [右辺値 (Value)] フィールドに式 arrayText(1) を追加します。
  16. Add another Assign activity and place it after the previous one.
    1. [左辺値 (To)/宛先] フィールドに変数 city を追加します。
    2. [右辺値 (Value)] フィールドに式 arrayText(2).Split(","c)(0) を追加します。
  17. Add another Assign activity and place it after the previous one.
    1. [左辺値 (To)/宛先] フィールドに変数 phoneNumber を追加します。
    2. [右辺値 (Value)] フィールドに式 arrayText(3).Split(":"c)(1).Split({"INVOICE"},StringSplitOptions.None)(0) を追加します。
  18. Add another Assign activity and place it after the previous one.
    1. [左辺値 (To)/宛先] フィールドに変数 invoiceNumber を追加します。
    2. [右辺値 (Value)] フィールドに式 arrayText(3).Split(":"c)(1).Split({"INVOICE"},StringSplitOptions.None)(1).Split("#"c)(1) を追加します。
  19. Add another Assign activity and place it after the previous one.
    1. [左辺値 (To)/宛先] フィールドに変数 vendor を追加します。

    2. [右辺値 (Value)] フィールドに式 arrayText(arrayText.Count-5) を追加します。

      Figure 2. Overview of the sequence containing the Assign activities

      [代入] アクティビティを含むシーケンスの概要

  20. Place a For Each activity after the If container.
    1. Values (値) フィールドに変数 arrayText を追加します。
  21. Add an If activity inside the Body container of the For Each activity.
    1. [条件 (Condition)] フィールドに式 item.Contains("Bank Name:") を追加します。
  22. Add an Assign activity inside the Then field.
    1. [左辺値 (To)/宛先] フィールドに変数 bankName を追加します。
    2. [右辺値 (Value)] フィールドに式 item.Split(":"c)(1) を追加します。
  23. Add an If activity after the previous one.
    1. [条件 (Condition)] フィールドに式 item.Contains("Bank Account:") を追加します。
  24. Add an Assign activity inside the Then field.
    1. [左辺値 (To)/宛先] フィールドに変数 bankName を追加します。
    2. [右辺値 (Value)] フィールドに式 item.Split(":"c)(1) を追加します。
  25. Add an If activity after the previous one.
    1. [条件 (Condition)] フィールドに式 item.contains("IBAN Code:") を追加します。
  26. Add an Assign activity inside the Then field.
    1. [左辺値 (To)/宛先] フィールドに変数 ibanCode を追加します。

    2. [右辺値 (Value)] フィールドに式 item.Split(":"c)(1) を追加します。

      Figure 3. Overview of the For Each activity

      [繰り返し (コレクションの各要素)] アクティビティの概要

  27. Return to the Read PDF Text sequence and add a Write Text File activity below the For Each activity.
    1. FileName フィールドに値 "InvoiceDetails.txt" を追加します。

    2. [テキスト] フィールドに "Invoice details"+Environment.NewLine+Environment.NewLine+"Vendor: "+vendor+Environment.NewLine+"Vendor address: "+address+Environment.NewLine+"City: "+city+Environment.NewLine+"Phone number:"+phoneNumber+Environment.NewLine+"Invoice number:"+invoiceNumber+Environment.NewLine+"Bank name:"+bankName+Environment.NewLine+"Bank account:"+bankAccount+Environment.NewLine+"IBAN Code:"+ibanCode を追加します。

      Figure 4. Overview of the For Each container

      [繰り返し (コレクションの各要素)] コンテナーの概要

  28. [Main] ワークフローの作業領域に戻ります。
  29. Read a PDF File using the Read PDF with OCR activity.
    1. Open the Read PDF With OCR sequence container.
    2. シーケンス内に [OCR で PDF を読み込み] アクティビティをドラッグします。
      1. FileName フィールドに値 "Invoice02.pdf" を追加します。
      2. [プロパティ] パネルで [並列度] フィールドに値 1 を追加します。
    3. [OCR で PDF を読み込み] アクティビティ内に Google OCR エンジンをドラッグします。
      1. [プロパティ] パネルの [テキスト] フィールドに変数 extractedTextTesseract を追加します。
    4. Drag another Read PDF With OCR activity and place it after the previous one.
      1. FileName フィールドに値 "Invoice02.pdf" を追加します。
      2. [プロパティ] パネルで [並列度] フィールドに値 1 を追加します。
    5. [OCR で PDF を読み込み] アクティビティ内に Microsoft OCR エンジンをドラッグします。
      1. [プロパティ] パネルの [テキスト] フィールドに変数 extractedTextMicrosoft を追加します。
    6. [OCR で PDF を読み込み] アクティビティの下に [テキスト ファイルに書き込み] アクティビティをドラッグします。
      1. FileName フィールドに値 "OCRMicrosoft.txt" を追加します。
      2. [テキスト] フィールドに変数 extractedTextMicrosoft を追加します。
    7. 前の Write Text File アクティビティの下に Write Text File アクティビティをドラッグします。
      1. FileName フィールドに値 "OCRTesseract.txt" を追加します。

      2. [テキスト] フィールドに変数 extractedTextTesseract を追加します。

        Figure 5. Overview of the Read PDF with OCR activity

        [OCR で PDF を読み込み] アクティビティの概要

  30. プロセスを実行します。ロボットは、指定されたプロセスを使用してデータを抽出し、出力を .txt ファイルに保存します。

Visit the following link to download the example as a ZIP format: Example.

    このページは役に立ちましたか?

    接続

    ヘルプ リソース サポート

    学習する UiPath アカデミー

    質問する UiPath フォーラム

    最新情報を取得