Using read pdf with OCR activity to read a pdf and extract its text.
Using invoke code activity to update metadata of that pdf with text extracted in step1.
Project language in json file - Visual Basic
Invoke code language - C#
Whenever i try to execute this, I get below exception thrown for invoke code:
Exception thrown by target of an invocation → Cannot access the file as file is in use by another program.
What can be the issue? I even tried to add delay(60 seconds) between 2 activities thinking may be file was not yet released by read pdf activity when invoke activity tried to use it. But still dint work.
I figured out what an error is. It is because in my code pdfReader is reading my file and my requirement is to update the metadata in the same file itself and not create new file. And now because it exists already and is being used, error is thrown while creating file with same name file.
if that’s invoked in a UiPath workflow in loop, you can create and delete the backup file in the UiPath flow too. just create the copy of file and pass that as an argument, use that file to extract data and the original file to just attach metadata. After this code is done, you can add delete file activity to get rid of that file
Regarding script, below is the code to be added, after the 5th line in your screenshot, and make sure you add a “Temp” between file path and file name in PdfStamper arguments