Read pdf directory

Hello! I have a folder on my local drive with alot of pdf files. I want to make two different functions for this.

1- Loop through all the pdf files and search for one specific word inside the pdf then extract the pdf data from that file when found

2- Go into each file and perfrom an action when done move to next one.

Thanks in advance


Try below steps:

  1. strPDFFiles [ ] = Directory.GetFiles(“FolderPath”,“*.pdf”)

  2. It will give array of files then use For Each loop to iterate that array of files.

ForEach item in strPDFFiles
- use Read Pdf text to read file and store output in a string variable and say ‘pdfText’
If pdfText.Contains(“requiredWord”)
Then: use Move File activity to move the file
Else: Skip it.

1 Like

Upon read pdf file. What shall i insert as the filename ?

1 Like


It should be item. Because we are looping it and item contains full file path. If it contains any password then pass it else no need.

And in Move File activity, source name should be item and destination you have to pass destination folder name.

Hm it cant find the file upon read

1 Like


Could you please take screenshot of your process and show me once. Will check it.

here thanks

1 Like


remove double quotes for item in Read PDF Text activity and then try.

DIdent get any error, but no file occured in the folderMain.xaml (8.9 KB)

If i put a text box right after the assign i get system


I checked your workflow and found two mistakes like:

  1. Declared variable of type string and named RegNR but you did not assign any value to this variable.

  2. In Move File activity, As i mentioned in earlier post From path should be item but you put FunnetReg.

And also before For each loop, take one mesaage box activity and print this value SjekkPdfFiler.count.Tostring and check once.
If it will give any error then that rmeans its did not find PDF files in that folder. Please check folder path properly. It looks like shared folder path. There may be chances of network disconnectivity.

THe RegNr its the value that gets retreive from the input box that the user types in.

In the message box i got 161 files, but it dident move anything to the folder

The pdf file looks like this invoice_80ss.pdf (47.9 KB)

Where it says BS10977 thats the value i want to check. So if the value that the user inputs in the text box at the beginning match the value thats inside the pdf file. I want then to move the pdf file to a folder