Read all from PDF and Paste into Excel

Hi Everyone,

How can I read all data from PDF and paste it into 1 single column in excel table?

Here is example of PDF and desired output.

DesiredOutput.zip (3.5 MB)

Regards
Hidayat

Hi @Md_Hidayat

First you have to install UiPath.PDF.Activities package

then read your pdf with read pdf text activity and store the output variable like Str

Drag and drop the matches activity and choose dropdown as Advanced and paste the regex **([\w\W]+(?=\n))**in value tab

create a output variable for matches activity like RegEx_Out
enter input string as read pdf text activity output variable

Build a datatable for output excel and create one column using build data table activity
and create a outpiut variable as Out_DT

use for each activity to iterate each line of pdf text and pass matches activity output in In Tab
image

Drag and drop the add data row activity inside the for each activity
and pass array row value as {item.ToString},datatable as Out_DT
image

use write range activity outside of the for each activity to print write the output and pass Out_DT variable

Thats it
Hope it solves your issue
update us whether you got your desired answer or not

Thanks
Robin

1 Like

Hi Robin,

Thanks for the quick assistance!

However the output is incorrectly processed.
Instead of each new line in a new row, Out_DT write range all data in A1, 1 single cell.

Output.xlsx (21.6 KB)

Regards
Hidayat

Can you replace regex as .*(?=\n)
and try again

Thanks,
Robin

1 Like

Hi @Robinnavinraj_S ,

There’s some output now! :grinning:
Is there a way to remove the line break or trim the whitespace?

Output.xlsx (26.0 KB)

Regards
Hidayat

Hi @Md_Hidayat

Use if activity to avoid line break

Ex item.ToString=“”

leave the then block as empty

and add the add data row activity in else block

use trim method to remove whitespaces Ex:Item.ToString.Trim

Hope it solves your issue

thanks
Robin

1 Like

Thank you so much @Robinnavinraj_S!
The feedback provided solves it. :+1:t3::grinning:

Your welcome

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