UiPath Documentation
activities
latest
false
Importante :
A tradução automática foi aplicada parcialmente neste conteúdo. A localização de um conteúdo recém-publicado pode levar de 1 a 2 semanas para ficar disponível.
UiPath logo, featuring letters U and I in white

Atividades do Document Understanding

Última atualização 22 de abr de 2026

Extração de dados baseada em âncora usando a atividade Intelligent Form Extractor

O exemplo abaixo explica como extrair dados de um formulário que também pode incluir texto manuscrito. O seguinte cenário de caso de uso explica como extrair dados de uma ordem de compra.

It presents activities such as Digitize Document, Data Extraction Scope, or Intelligent Form Extractor. You can find these activities in the UiPath.IntelligentOCR.Activities package.

Como criar o fluxo de trabalho

Os seguintes pacotes precisam ser instalados antes de criar o fluxo de trabalho abaixo:

  • UiPath.DocumentProcessing.Contracts.Activities
  • UiPath.IntelligentOCR.Activities
  • UiPath.OCR.Activities
  • UiPath.OCR.Contracts
  • UiPath.WebApi.Activities

Steps:

  1. Abra o Studio e crie um Processo.

  2. Add a Sequence container in the Workflow Designer, name it Sequence1, and create the variables shown in the following table:

    Table 1. Variables to be created

    Tipo de VariávelValor padrão
    itemStringN/A
    classificationResultClassificationResult[]N/A
    outputFileNameGenericValueN/A
  3. Add another Sequence container in the Workflow Designer, after the first one, name it Sequence2, and create the variables shown in the following table:

    Table 2. Variables to be created

    Tipo de VariávelValor padrão
    textStringN/A
    taxonomyDocumentTaxonomyN/A
    domDocumentoN/A
    documentPathStringN/A
    classificationResult2ClassificationResult[]N/A
    outputFileName2GenericValueN/A
  4. Add a Message Box activity inside the sequence.

    • In the Properties panel, select the Ok option from the Buttons dropdown. Add the following message in the Text field: "Select a PDF file".
  5. Marque a caixa de seleção para a opção Superior. Isso traz a caixa de mensagens para o primeiro plano.

  6. Add a Select File activity after the Message Box activity.

    • In the Properties panel, add the following text in the Filter field: Pdf files (*.pdf)|*.pdf
    • Add the documentPath variable in the SelectedFile field.
  7. Add an Assign activity after the Select File activity.

    • Add the outputFileName2 variable in the To field.
    • Adicione a expressão ".temp/" + Path.GetFileName(documentPath) no campo Valor.
  8. Add a Deserialize JSON activity after the Assign activity.

    • Add the expression File.ReadAllText("DocumentProcessing axonomy.json") in the JSON String field.
    • In the Properties panel, select the UiPath.DocumentProcessing.Contracts.Taxonomy.DocumentTaxonomy option from the TypeArgument dropdown list.
    • Add the taxonomy variable in the JsonObject field.
  9. Add a Digitize Document activity after the Deserialize JSON activity.

    • In the Properties panel, add the value 1 in the DegreeOfParallelism field.
    • Add the documentPath variable in the DocumentPath field.
    • Add the dom variable in the DocumentObjectModel field.
    • Add the text variable in the DocumentText field.
    • Add the UiPath® Document OCR engine inside the activity.
    • Add your API Key inside the ApiKey field.
    • Add the "https://du.uipath.com/ocr" expression in the Endpoint field.
  10. Add a Write Text File activity after the Digitize Document activity.

    • Add the JsonConvert.SerializeObject(dom) expression in the Text field.
    • Add the outputFileName2 + ".dom.json" expression in the FileName field.
  11. Add another Write Text File activity after the Write Text File activity.

    • Add the text variable in the Text field.
    • Add the outputFileName2 + ".text.txt" expression in the FileName field.
  12. Drag another Sequence container in the Workflow Designer, name it Sequence3, and create the variables shown in the following table:

    Table 3. Variables to be created

    Tipo de VariávelValor Padrão
    extractionResultExtractionResultN/A
    validatedResultsExtractionResultN/A
    doubleValidatedResultsExtractionResultN/A
    datasetConjuntoDeDadosN/A
    iInt32N/A
  13. Add a Data Extraction Scope activity inside the Sequence3.

    • In the Properties panel, add the dom variable in the DocumentObjectModel field.
    • Add the documentPath variable in the DocumentPath field.
    • Add the text variable in the DocumentText field.
    • Add the "All.Benchmarks.Invoice" expression in the DocumentTypeId field.
    • Add the taxonomy variable in the Taxonomy field.
    • Add the extractionResult variable in the ExtractionResults field.
  14. Add an Intelligent Form Extractor activity inside the Data Extraction Scope activity.

    • Add your API Key in the ApiKey field.
  15. Add a Write Text File activity after the Data Extraction Scope activity.

    • Add the JsonConvert.SerializeObject(extractionResult) expression in the Text field.
    • Add the outputFileName2 + ".results.json" expression in the FileName field.
  16. Add a Present Validation Station activity after the Write Text File activity.

    • Add the extractionResult variable in the AutomaticExtractionResults field.
    • Add the dom variable in the DocumentObjectModel field.
    • Add the documentPath variable in the DocumentPath field.
    • Add the text variable in the DocumentText field.
    • Add the taxonomy variable in the Taxonomy field.
    • Add the validatedResults variable in the ValidatedExtractionResults field.
  17. Add a Write Text File activity after the Present Validation Station activity.

    • Add the JsonConvert.SerializeObject(validatedResults) expression in the Text field.
    • Add the outputFileName2 + ".savedinVS.results.json" expression in the FileName field.
  18. Add another Write Text File activity after the Write Text File activity.

    • Add the JsonConvert.SerializeObject(doubleValidatedResults) expression in the Text field.
    • Add the outputFileName2 + ".doubleSavedinVS.results.json" expression in the FileName field.
  19. Execute o processo. O processo de automação deve abrir a Estação de Validação, extrair os dados, validá-los e armazená-los na pasta Saída.

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

Definindo sua taxonomia

You have created your workflow, defined all variables, and customized all activities. Now it's time to define your taxonomy. Visit Load Taxonomy to learn about defining your own taxonomy.

Create your taxonomy to be able to extract information from an invoice. You should be focused on creating an Invoice document type, with the fields shown in the following table:

Table 4. Invoice document type fields

Tipo de Campo
Nº da FaturaText
SubtotalNumber
Imposto sobre vendasNumber
TotalNumber

Figure 1. Overview of the finished taxonomy with the previously mentioned fields

Visão geral da taxonomia concluída com os campos mencionados anteriormente

Criar seu modelo

It is now time to create the template for the extraction process. Visit Load Taxonomy to learn how to create a template.

Para esse exemplo, configure o modelo usando os seguintes valores:

  • Document Type: Invoice.
  • Template Name: Invoice-example.
  • Template Document: Select the target file.
  • OCR Engine: Microsoft OCR.
  • Languages: en.
  • Profile: Scan.
  • Scale: 1.

Figure 2. Animated image example showing the configuration of the template

Exemplo de imagem animada mostrando a configuração do modelo

Definir âncoras no modelo

As âncoras são um recurso muito especial e útil para usar quando você precisa extrair informações precisas de um documento. Ao definir uma área de extração com uma âncora, você pode esperar uma alta precisão na extração de dados.

Uma vez definida a taxonomia e criado o modelo, você pode começar a configurar o modelo usando âncoras, o que significa que a área de extração é definida em uma caixa e as âncoras são usadas para definir a posição da caixa.

Verifique a lista a seguir para alguns ponteiros antes de começar a adicionar âncoras ao seu modelo:

  • A caixa âncora deve ser o maior possível (altura, largura) para cobrir qualquer tipo de número de fatura, fonte longa, curta, grande, etc.
  • Uma área de extração pode ter quantas âncoras forem necessárias, mas apenas uma definida como principal (a primeira).
  • Use âncoras formadas por várias palavras lado a lado.
  • A âncora principal deve estar o mais próximo possível da área de extração.
  • As posições da área de extração e da âncora principal são fixadas no template, mesmo quando aplicadas a documentos diferentes. A única coisa que pode variar é a distância entre a âncora principal e as secundárias.

Vamos continuar configurando o modelo e ver como você pode extrair dados usando uma âncora.

  1. Defina a área de extração:
    • In the right area of the Validation Station, select Selection modes.

    • Select Anchor.

    • Comece a selecionar a área desejada.

      Observação:

      A âncora principal deve conter duas ou três palavras para maior precisão e melhores resultados no processo de extração.

      Selecione várias palavras ao marcar uma âncora pressionando CTRL e selecionando as palavras desejadas.

  2. Defina a âncora principal:
    1. While still in the Anchor selection mode, select the desired area as your main anchor.
    2. Select Extract value for the desired field.
  3. Defina as âncoras secundárias:
    1. Ensure you're still in the Anchor selection mode, and with the main anchor selections activated.
    2. Selecione as novas áreas para as âncoras secundárias.
    3. Select Options for the desired field, and then select Change extracted value.

Repita o processo até terminar de definir todas as áreas de extração e adicionar todas as suas âncoras. Depois de concluído, salve o modelo.

Esta página foi útil?

Conectar

Precisa de ajuda? Suporte

Quer aprender? Academia UiPath

Tem perguntas? Fórum do UiPath

Fique por dentro das novidades