Read XPS files
The example after explains how to read an .xps file, extract the data, and provide the output in two message boxes by using Read XPS Text or Read XPS With OCR activities. You can find these activities in the UiPath.PDF.Activities package.
Steps
- Open Studio and create a new Process.
- Drag a Sequence container in the Workflow Designer.
- Create the variables from the following table:
Table 1. Variables to be created
| | **Variable Type** | **Default Value** |
| --- | --- | --- |
| `ExactString` | **String** | N/A |
| `ExtractWithOCRString` | **String** | N/A |
:::note
Add your `.xps` files to the project directory in order to be able to run the entire process from the same place.
:::
3. Drag a Read XPS Text activity inside the Sequence container.
- In the Properties panel, add the expression
"XPSTextDemo.xps"in the FileName field. - Add the value
"All"in the Range field. - Add the variable
ExactStringin the Text field.
- Place a Message Box activity after the Read XPS Text activity.
- In the Properties panel, select the Ok option from the Buttons dropdown list.
- Add the variable
ExactStringin the Text field. - Select the check box for the TopMost option for always having the message box displayed to the foreground.
- Drag a Read XPS with OCR activity after the Message Box activity.
- In the Properties panel, add the expression
"XPSOCRDemo.xps"in the FileName field. - Add the value
1in the DegreeOfParallelism field. - Add the value
"1"in the Range field. - Add the variable
ExtractWithOCRStringin the Text field.
- In the Properties panel, add the expression
- Place a Microsoft OCR engine inside the Read XPS with OCR activity.
- Drag a Message Box activity after the Read XPS with OCR activity.
- Add the expression
ExtractWithOCRStringin the Text field. - In the Properties panel, select the Ok option from the Buttons drop-down list.
- Select the check box for the TopMost option for always having the message box displayed to the foreground.
- Add the expression
- Run the process. The robot extracts the data using the specified process and provides the output in two message boxes.
Visit the following link to download the example in a ZIP format: Example.