READ PDF TEXT OUTPUT CONTROL

I added an ‘If’ activity to check whether the text extracted using the ‘Read PDF Text’ activity is successfully extracted or not. However, when I use the String.IsNullOrWhiteSpace or String.IsNullOrEmpty functions, it doesn’t recognize the text even when there is content. What should I do?

Hi @mina.dilek

If the output is coming in string format you can check the length of content and specific condition according to your requirement.

Regards
Naman Jain

The output comes in text format

@mina.dilek,

That’s not how it designed. It should recognize if the variable have any value or not.

Could you share the screenshot how you are trying it.

Thanks,
Ashok :slight_smile:


The ‘Else’ part of the ‘If’ activity is being executed, but there is data inside. I am printing it using a log message.

Hi @mina.dilek

Try this way, Use the below condition in the If condition

String.IsNullOrWhiteSpace(myText) or String.IsNullOrEmpty(myText)

Regards,
Gowtham Krishnan

The If condition should be “Not String.IsNullOrWhiteSpace(myText)”.

A couple of other things:

  • You don’t need to trim the string when using String.IsNullOrWhiteSpace.
  • Your string split looks a bit strange.

Unfortunately, it is still going to the ‘Else’ part

I saw a few posts on the forum thinking it might help, but there was no change

That doesn’t make sense; however if that’s the case, moving the assign operation into the else block may do the trick for you!

@mina.dilek,

That’s odd. Log the myText before the if activity to see what’s the value being evaluated.

hi, Sometimes, PDFs have hidden special characters or newlines, making the text appear empty. To check if there’s actual content, try this:

pdfText.Trim().Length > 0

1 Like

I think you should do what @Anna_Kozaczyk suggested as there can be some unprintable characters that make UiPath consider string not to be empty.
I even suggest going further and putting a breakpoint right after Read PDF Text and then you’ll have access to Immediate window where you can:
Execute suggested expression pdfText.Trim().Length
If it’s giving you value higher than 0, then you can check with Asc(pdfText(0)) and cross check retruned value with https://www.asciitable.com/ so you’ll know exactly what it is that makes UiPath not consider this string to be empty.
You can increase numers Asc(pdfText(1)), Asc(pdfText(2)) and so on until you get an error meaning you’ve reached end of the string.

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