Read every PDF files with OCR

Hello everyone,
I can’t read every PDF files with OCR using For Each File In Folder activity.
The problem is keep reading only 1 PDF file which is chosen in READ PDF WITH OCR activity.
How do I fix this? Please help.

Regards,
Temuulen

Hi @Temuulen_Buyangerel ,
You can use for each file in folder to read all file
Regards,
LNV

1 Like

Hi @Temuulen_Buyangerel


Hope it helps!!

1 Like

I tried but It’s keep reading only one file

Hi @pravallikapaluri
It says
System.ArgumentException: Argument ‘Length’ must be greater or equal to zero. (Parameter ‘Length’) at Microsoft.VisualBasic.Strings.Right(String str, Int32 Length)
at Namespace_7e8b.Main_Expressions.Main_Expressions_TypedDataContext3_ForReadOnly.__Expr10Get()
at Namespace_7e8b.Main_Expressions.Main_Expressions_TypedDataContext3_ForReadOnly.ValueType___Expr10Get()
at Namespace_7e8b.Main_Expressions.InvokeExpression(Int32 expressionId, IList1 locations, ActivityContext activityContext) at System.Activities.Expressions.CompiledExpressionInvoker.InvokeExpression(ActivityContext activityContext) at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context)
at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context) at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity)
at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor) at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath) at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate)
at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary`2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

I think I need first page of every pdf files so the Range of Read PDF With OCR must be 1 right?

Hi @Temuulen_Buyangerel

You are using Both Scanned and Normal PDF’s in One Folder so try like this
Take the output of Read PDF with OCR activity if length<0 means it is normal pdf so it goes to extract Read PDF Text activity.

I hope it helps!!

1 Like

I think no,Change the range to “All” and try

1 Like

Hi @Temuulen_Buyangerel

If the pdf file name is specific that you want to read then we will write a condition
Inside for each file in folder, Place If condition activity in that activity write the below condition

CurrentFile.Name.eqauls("Give the specific pdf file name here")

In then block give the Read PDF with OCR activity.
In else block give only Read PDF activity.
Give the same variable to the Output for both activities then the output will be same.

If we give if condition when the required pdf file comes it will go to Read PDF with OCR activity.

Hope it helps!!

1 Like

I tried but still not working
It says
Message: Object reference not set to an instance of an object.

Hi,


I tried it OK, can you try flow image
Regards,
LNV

1 Like

The error is the same as range is “1”

Ok @Temuulen_Buyangerel
Try this

hi @Nguyen_Van_Luong1
it’s just like mine but not working

Is this doesn’t help for you @Temuulen_Buyangerel

Hi @Temuulen_Buyangerel ,
Can you share your code and your folder, your file you want to read?
Regards,
LNV

Hi,
Sorry, I haven’t tried yet.
A sec

It did work!
I’ve tried on new PDF files and I works.
It seems the old pdf files were cannot be scanned I guess.
Thanks all

Hi,
Can you share your old pdf by image?
For each file in folder, if it is PDF, robot will read all .
Regards,
LNV

Sorry, I can’t upload for some reason.
Regards,
Temuulen

1 Like