can you check the value what was the value it is getting
readpdf.IndexOf(“service Date”)
Hi @Madhu_Maurya ,
Would suggest you to check the Expression in the Debug Panel Immediate window, I believe the Expression readPdf.IndexOf("Service Date")
provides result as -1, which might be the reason for the error.
If the word is not present as mentioned in the Text data, then it does give out the same error mentioned.
Hi @Madhu_Maurya ,
If its -1 , then it means the indexof is not able to findout the keyword what u are looking for
Value more than 0 means indexof returns the position of keyword u are looking for
Make sure u use .contains method first to see the keyword is avilable in the string the if its true use the index of
Happy Automation
Happy automation
its value should start from 0 not from -1
substring should start its index from 0 ,you are passing -1 its showing error
It depends on what you want to do when there are no words in the text data having “Service Date”,
You could use an If condition and check whether the IndexOf() method returns -1, if not then perform the Substring operation, else Throw an Error or do a custom operation accordingly as needed.
If u can see that u are actually searching for readPdf.IndexOf(“Service Date”)
Instead search for readPdf.IndexOf(“Service”).
Since Date will be in the newline u are getting this error .
Happy Automation
so need to pass this expression readPdf.IndexOf(“Service”)
Hi @Madhu_Maurya ,
after reading the pdf , make sure u are writing the data in atext file to see first of all , how the data is being read and stored in a string variable .
instead of wring the expression all at once and go step by step .
which will help u to see how ur code is giving results .
Happy Automation
@Madhu_Maurya
As @supermanPunch guided you just continue and check the readPDF Variable within the immediate panel
Here you can check if the linebreak leads to this not found issue as maybe the text is:
Service … Type o Service …
Date …
lets scope and focus on your initial issue.
type in the variable name ReadPDF into the immediate panel and check the string. Feel free to share with us e.g. as screenshot
The above requirement seems like the Topic that was previously created but no further comments/feedback was provided to it.
As this current Topic states or works on String manipulation we did clarify the issue on the String Function IndexOf(). So on the String manipulation part, we could maybe come to conclusion and close this topic ?