Find "Total" in PDF

Good morning,

I have a process where I have to find the “Total” amount in the “Pad” column of a PDF. I have the company number stored as a variable. The company number (underlined in red) is in the first column and the total amount is in the 3rd column. The total amount (circled in red) is always one row below the company number. Sometimes however, there can be several lines for each company and sometimes there is only one. Can someone please help me solve this? I’m totally stumped.

Forum Example.pdf (22.9 KB)


Look for TOTAL in “Fund” column. The company number will be 1 row upper and the total amount in the same row.


Init. CustomerNumber = “”

  • Get nex row
  • check for “Fund” == “TOTAL”.
    • If True, get the amount, (you already have the customerNumber).
  • Get the customerNumber
  • Repeat until row exhaustion

Thank you @msan. I still don’t quite understand what you mean. Can you please attach a process where you’re able to get it to work? You can just hardcode the Company number variable to 420 and I should be able to figure it out from there.

Thank you again for your help.

customerNumber is initialised with any value.

  1. Convert PDF to text
  2. Use an IO.StringReader
  3. Iterate over the StringReader
    • If the line starts with TOTAL, you use the stored customerNumber with values of this line
    • in any case, if the first value is a suitable customer number, store it for next line
    • next line

An example is attached (you need UiPath.PDF.Activities)


FindTotalInPdf.xaml (11.7 KB)


Thank you @msan. This is definitly past my current skillset. I’m getting an error at the end:
Validation Error: compiler error(s) encountered processing expression “IsNumeric(fields(CUSTOMER_IDX))”.
Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class. FindTotalInPdf.xaml
Forum Picture


That’s strange: I ran it without any problem before sharing it. Could you please click on the “Analyse File” button in the rubbon? Sometimes, it fixes Studio’s bad temper.

Did you tried it with another excel file?

I just downloaded then run it, got expected warning about unknonw Read PDF Text activity, installed UiPath.PDF.Activities package, run it again, had the wrong path to Excel, copied the file and finally got expected result.

I tried to analyze the file but still get the warning. I updated the PDF location to a location my PC but that’s the only thing I have changed.
FindTotalInPdf_RG.xaml (12.1 KB)

Run smooth. Maybe a dependency problem? (We don’t need Excel or Mail obviously :slight_smile: )


@msan, yep, it was the system.activities. THANK YOU!!

1 Like

@msan hopefully you can help me with one last thing. I have put everything from your process into my existing file but I can’t figure out one last piece.

At the beginning of my process I read an Excel file and store as a DT. One of the fields stored is the company number. For this example, I’ll use company 416. When I read the PDF I am getting the Total for each company in the PD.
I only need the total for the current company I’m dealing with (in this case the total for company 416 is 4,550.00.

I’ve been trying for hours to find a way to filter that but I haven’t been able to. Do you know what I’m missing? The section of the process is the sequence named “PAD.”
Oper_FS No Commission V2.xaml (144.9 KB)

Hi @rgardner5564

You should keep track of the CustomerNumber like in the example I uploaded (the part with the isNumeric check).

At the condition to check for “TOTAL”, you can add a customerNumber match ie

CustomerNumber = SearchedCustomerNumber And Fields(0).Trim = "TOTAL"

EDIT: I’m dead tired, it doesn’t help my english. If I’m not clear just tell me: I’ll find you comment tomorrow morning. :wink:

Your English is great :slight_smile:. I’m just still the one who isn’t getting it correct.

Can you please put the activity where it needs to go in my file and reattach? Even I should be able to get it corrected at that point :wink:
Oper_FS No Commission V2.xaml (145.8 KB)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.