hey i'm cameron mackenzie at cameronmcnz on twitter and i want to talk to you about extracting
data from pdf files now specifically i want to talk to you about extracting individual fields
in your pdf files i got another tutorial that does screen scraping and more generic stuff another one
that does scraping of tabular data in this case i want to talk about grabbing specific fields
from a single pdf file i want to show you how to do that in uipath as always we're going to kick
this off by creating a new process project i'm going to call this extract my pdf data
allow the project to be created and once it's created i'm going to open the main
window for workflow now i've got a couple of pdf files here it's in this folder named attachments
and that first one is the one that i'm going to start extracting data on i'm only going to do this
for one pdf right now if you stick around for further tutorials i'll go through a bunch of pdfs
and process all the pdfs in a directory at once but right now i'm just going to concentrate on
extracting data from one pdf file and specifically i want to get the date i want to get the invoice
number and i want to get the total for the invoice that's the three pieces of data that i want off
this particular invoice now this invoice is called order dash 1001-pdf and it's in the c attachments
folder and so i need to use that information and have uipath create a brand new process
that opens up that pdf file in a new window and the way you do that is you go over here
you've got your drop activity here i want to find the start process activity there it is
system application start process drop that in here and in quotes the process that i want to start
is that order dash 1001.pdf i want to open that pdf file and that's going to kick everything off
okay now that's the start the next thing i need to do is tell uipath that it's actually the adobe
acropat reader that i want to start working with and so that means the next step is i've got to
attach that whole adobe pdf process to this sequence there's something called the attach
window process you can see right there attach window ui automation window drag that over here
and that's going to make it possible for me to run the pdf file and and open that up and
extract some of its data now right now it just thinks i'm going to open up any old
window it doesn't know which one to open up so notice it's got indicate window on screen
i need to kind of minimize this a little bit
and be able to get the pdf file on the screen at the same time i click indicate which window we
want to work with and then i click on this pdf file here and then uipath now knows okay it's
that pdf file i want to work with by the way it sometimes in this edit selector it specifies the
file name so notice it specified the file name and what to open up i like to deselect that and
then maybe click validate make sure that's okay if you're looping through a bunch of different files
and you've specified the name of the file in here it's not going to work so it doesn't really matter
for us we're only going to go on one pdf file for this example but just in the future you know
you might want to deselect that if you know all your files don't have the same name
okay so this is a good start now we've got that file open now what's the next thing we
want to do well i want to get some text so you can go up here and search for get
text where is it it's under ui automation element control get text and i'm going to scroll that over
there and what do i want to grab well i'm going to grab that date i'm going to scroll over here
indicate element inside window it's that date field okay so that's looks like it's
going to grab the date i want to do the same thing exactly the same just differently and i
want to get the invoice number so now i click on the invoice number for get text and then finally
make sure you scroll down on the window so that it's visible i want to get the total
so i'm going to do get text one more time indicate element inside window and now i'll highlight the
total and now i've got three different processes activities in here which are going to get the
the different values for the what looks like the date the invoice and the total now if you want to
hold on to that information you have to create variables so i'm going to create a variable called
invoice date i'm going to create a variable called invoice number and i'm going to create
a variable called invoice total so those three variables are created and for the
date get text under this output value i'm going to specify the value as invoice date
and right here where we get the invoice number the output value
when that runs when it gets that text we want it to assign it we want to assign it to invoice
number and then finally when we get down to this total we want to assign that output to invoice
and so now we have the file being loaded we have the adobe acrobat program being run
we then have some measure of screen scraping or data extraction to be more exact
for the date the invoice number and the total we've got that as variables in here
and then finally maybe i can just print that out to you if you just don't believe
right so look for my message box here
throw the message box there and i can just well i can just reference those variables so invoice date
plus
space plus invoice number
plus a space
plus invoice total
and you got to spell things correctly invoice total does that look good my little bad arrow
my mis my error little arrow went away so i think that looks good uh yeah that doesn't look too good
making it 42 but yeah i think you get an idea just looking at it again the sequence start the process
attach the adobe window get the different text fields and make sure that they're assigned their
appropriate values invoice number invoice total and then when it's done well we're just going to
print that information out to the user now by the way you can do anything here you could save it to
a csv file you could save it to microsoft word you could email it to somebody so what you do
is up to you you know but this does get the data into your program into uipath
okay i'm going to save that i'm actually going to close that window i'm going to run the program
you notice adobe comes up and then it prints out this message it says hey here's the date looks
like you got the date right here's the invoice number looks like i got the invoice number right
1455. magically it did it and i can't even see that down there oh there it is there's the total
and as you can see we got everything in there and so that's how easy it is to just get uipath
to start extracting data from a pdf and there you go that's how easy it is to extract data
from your pdf file so if you enjoyed this tutorial i want you to head over to theserverside.com i'm
the editor-in-chief over there we've got lots of great articles on that site if you want to
follow my personal antics i'm at cameronmcnz on twitter and you should subscribe on youtube