Write Line - Object reference not set to an instance of an object

Yes Null result.

In which part of the workflow should I add the assign function with the lineCount?
Also this problem came up when I did:

Draft.V2.xaml (13.8 KB)

I have put the IF function at the end of the workflow, or should it be right after the OCR reader?

InputStr is the variable having the value after read pdf with ocr.
If you have already declared another varibale. Use that instead of InputStr

I have the output as pdfTextStr

So I changed the code to: pdfTextStr.Split({Environment.NewLine}, StringSplitOptions.None).Count
but it is not working still and I placed it after the OCR reader which states dissalowing conversions from integer to string

LineCount should be an integer variable

So I should change using writeline?

Please I need help I am a beginner. I really appreciate it.

No…did you declared the variable “LineCount”?

I am trying but this comes up

Convert your variable type to int32 from Variable panel at Bottom Left In Uipath.

Thank you sboo1 I appreciate it.
Unfortunatelythe solution I was seeking is not working still after fixing this error.

The idea from this workflow Draft.V2.xaml (15.2 KB) is to rename files depending on the numbers retrieved from the OCR. The problem was if there was one file not readable by the OCR, the program stops wokring for all files. Rahul recommended that I add LineCount and an IF function If: LineCount>0, then it continues the workflow as it should, ELSEIF it should copy file to another folder. This errror came up now:

Have you checked Your pdfstrvar is getting any output or not?
If not, Than you can also try by using Microsoft Ocr instead of Terresect Ocr.

I changed from Microsoft to Tessaract as it was working better on my sample files.
The output shows it retrieved the numbers from one PDF as shown in the image below, but not from the other PDF (I have only 2 PDFs in the folder)

Is this an output of pdftextvar which you have passed as input in matches activity?.

Yes. I am uploading 2 screenshots to confirm.

I have attempted another way and still not working. I included the IF function after the Match function (the output is “results” in the match function, and used IF results.count>1. This method still did not function and gacve me same error

Please advise

This was the solution all along. Thank you Sajid!

1 Like

you should use results.count >= 1

equal to one or more

Why not >0?

You can write any one of Both Conditions, Both Conditions will give you same result.
results.count>=1 or results.count>0.

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