Chapter - 12 PDF

21 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€95.86
List Price:  €134.21
You save:  €38.35
£79.54
List Price:  £111.35
You save:  £31.81
CA$143.56
List Price:  CA$200.99
You save:  CA$57.43
A$159.95
List Price:  A$223.94
You save:  A$63.98
S$135.54
List Price:  S$189.77
You save:  S$54.22
HK$777.41
List Price:  HK$1,088.41
You save:  HK$310.99
CHF 89.37
List Price:  CHF 125.13
You save:  CHF 35.75
NOK kr1,131.89
List Price:  NOK kr1,584.70
You save:  NOK kr452.80
DKK kr715.08
List Price:  DKK kr1,001.15
You save:  DKK kr286.06
NZ$176.78
List Price:  NZ$247.50
You save:  NZ$70.72
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳11,900.85
List Price:  ৳16,661.67
You save:  ৳4,760.81
₹8,494.03
List Price:  ₹11,891.98
You save:  ₹3,397.95
RM450.75
List Price:  RM631.07
You save:  RM180.32
₦154,505.46
List Price:  ₦216,313.83
You save:  ₦61,808.36
₨27,720.51
List Price:  ₨38,809.83
You save:  ₨11,089.31
฿3,419.79
List Price:  ฿4,787.84
You save:  ฿1,368.05
₺3,506.82
List Price:  ₺4,909.70
You save:  ₺1,402.87
B$608.53
List Price:  B$851.97
You save:  B$243.44
R1,831.63
List Price:  R2,564.36
You save:  R732.72
Лв187.37
List Price:  Лв262.33
You save:  Лв74.95
₩144,627.53
List Price:  ₩202,484.33
You save:  ₩57,856.80
₪363.83
List Price:  ₪509.39
You save:  ₪145.55
₱5,882.91
List Price:  ₱8,236.31
You save:  ₱2,353.40
¥15,642.93
List Price:  ¥21,900.73
You save:  ¥6,257.80
MX$2,007.92
List Price:  MX$2,811.18
You save:  MX$803.25
QR363.05
List Price:  QR508.28
You save:  QR145.23
P1,376.48
List Price:  P1,927.13
You save:  P550.64
KSh12,857.29
List Price:  KSh18,000.72
You save:  KSh5,143.43
E£5,087.81
List Price:  E£7,123.14
You save:  E£2,035.32
ብር12,414.52
List Price:  ብር17,380.83
You save:  ብር4,966.30
Kz91,790.82
List Price:  Kz128,510.82
You save:  Kz36,720
CLP$98,780.55
List Price:  CLP$138,296.72
You save:  CLP$39,516.17
CN¥729.56
List Price:  CN¥1,021.42
You save:  CN¥291.85
RD$6,064.47
List Price:  RD$8,490.50
You save:  RD$2,426.03
DA13,486.35
List Price:  DA18,881.43
You save:  DA5,395.08
FJ$231.62
List Price:  FJ$324.28
You save:  FJ$92.66
Q767.35
List Price:  Q1,074.32
You save:  Q306.97
GY$20,835.60
List Price:  GY$29,170.68
You save:  GY$8,335.07
ISK kr13,848.23
List Price:  ISK kr19,388.08
You save:  ISK kr5,539.84
DH1,002.31
List Price:  DH1,403.28
You save:  DH400.96
L1,836.70
List Price:  L2,571.46
You save:  L734.75
ден5,897.23
List Price:  ден8,256.37
You save:  ден2,359.13
MOP$797.27
List Price:  MOP$1,116.21
You save:  MOP$318.94
N$1,833.49
List Price:  N$2,566.96
You save:  N$733.47
C$3,664.75
List Price:  C$5,130.79
You save:  C$1,466.04
रु13,546.73
List Price:  रु18,965.97
You save:  रु5,419.23
S/370.84
List Price:  S/519.19
You save:  S/148.35
K403.85
List Price:  K565.40
You save:  K161.55
SAR375.59
List Price:  SAR525.84
You save:  SAR150.25
ZK2,756.13
List Price:  ZK3,858.69
You save:  ZK1,102.56
L477.10
List Price:  L667.96
You save:  L190.86
Kč2,408.98
List Price:  Kč3,372.68
You save:  Kč963.69
Ft39,690.03
List Price:  Ft55,567.63
You save:  Ft15,877.60
SEK kr1,103.14
List Price:  SEK kr1,544.45
You save:  SEK kr441.30
ARS$101,779.64
List Price:  ARS$142,495.57
You save:  ARS$40,715.92
Bs688.19
List Price:  Bs963.50
You save:  Bs275.30
COP$435,927.07
List Price:  COP$610,315.34
You save:  COP$174,388.27
₡50,246.58
List Price:  ₡70,347.23
You save:  ₡20,100.64
L2,528.04
List Price:  L3,539.36
You save:  L1,011.31
₲776,552.46
List Price:  ₲1,087,204.52
You save:  ₲310,652.05
$U4,441.97
List Price:  $U6,218.94
You save:  $U1,776.96
zł408.81
List Price:  zł572.35
You save:  zł163.54
Already have an account? Log In

Transcript

Chapter 11 PDF automation. In this chapter, we'll be going through an overview of what PDF automation includes. We'll go through activities for large data extraction, and we'll also go through the activities for specific data extraction. Overview. pdf stands for portable document format. It is one of the major file formats used today to send over documents between computer systems, irrespective of their OS, hardware or any software limitations.

It preserves all the data such as images, text, spreadsheets, and supports interactive buttons, hyperlinks, embedded objects and more. UiPath has a separate package for PDF activities that provides user basic operational capabilities. In this chapter, we'll be discussing the ways to extract data from PDF. Identify elements using selectors and other similar actions. Okay, so PDF files can hold text, images or in some cases, text as images. Like, you know, let's take an example.

I have two PDF files on my desktop here. One is says the invoice where if you want to check whether it's a text or it's a, you know, image. If it is selectable, then of course it is text, you can see, I can select this data in the PDF, right. But this figure, which is another app, right? If I try to select it, nope, I can't select this. This is an image.

So that's how you can just quickly distinguish between an image and a text. And we have different methodologies to extract data under different circumstances within UiPath But in general, we classified them under two categories, large data extraction, and specific data extraction. large data extraction. So, in logic extraction, we have two major activities, and one additional capability as well, which is there in the UiPath to extract data from either all the pages or from the selected pages of the PDF document. Right. So, first activity is read PDF text.

Read PDF text activity is used to read the whole PDF document or its complete pages at once. It's the simplest, yet reliable activity to use, where the location of the PDF file is provided as input. And a text variable is generated as output. And in properties, we can set the range like which is all by default to get text for specific pages or a range of pages. Right note that you know will be only two In the selectable texts through this activity, so say you have read PDF text, and just a second Let me open this with the Adobe Adobe Reader because that's like the generic norm instead of the other applications. So to get to the file name, we'll have to provide the directory information for this.

Okay. We read the data, right? And we have a text variable, which is the output and byte range it is all and either we can do that or we can provide it with the specific page numbers. Like the way we do it in print command as well, right? If we do it like one to five then. And if my PDF document, of course has like more than five pages, I can print it like that.

I can print like 136, you know. So that means the data from these three pages would be scraped, and so on. Right now we're using all which is like by default, or in this case, it's going to be, I guess, just one page. You can check. Yes, it's just one page and the text variable. We don't have a text variable, do we have a data variable, we'll use that variable itself.

Right? And let's improve print that in a right line. There's going to be huge text. So I don't want to send message box data. Okay. So very simple activity, not too much of, you know, properties to play around with, and it is very reliable because any editable or selectable text would be scraped through this app.

Also, if your file is password protected, right, you can provide the password in this field and the file would be like able to be read by the bot. If the back of course if the credential matches. Okay, let's run this. And it's done. Okay, let's see the output and here it is. We have all that data payment is due within 30 days page one on one demo this and your city and some address and stuff.

So all data is read correctly. Fairly easy activity to use. Okay. Next, next is read PDF with OCR. Okay. So, as I said, right, OCR is always always challenging, but I mean, this is you must be getting a pretty good hold of it.

Now, so, read PDF with OCR is like to scrape data contained in images within the PDF documents we use this activity, right and the file name along with its path along with its path and if the password is there like same as the previous activity, I provided as the input and output is generated as a string variable. And the range again can be either selected pages. A sequence of consecutive pages are all the pages as is given by default. Right and we need to select the relevant OCR engine the same way we have been doing so far. So let's try and use this. Do we have no, not this one.

What we'll do is we'll go to the desktop We'll use this location slash trigger dot PDF. Okay, so that's how we got the file name and the directory location where it needs to access. Then we need to select, we need to give an output variable as well, let's use the data itself because we have that ready and we're not using it anywhere for the OCR engine, right? So we have to OCR is already there, Google and Microsoft. Well, I think that Microsoft would be a better option because you know, it's suitable for large text and based on the image, see, again, that depends on you being like playing around with this. But if we use Google OCR, just you know, for to see how it works.

Right? And that's the engine that has been chosen to scrape the data, we can probably increase the scaling a little bit. And if we use right line activity to bring the value of, Okay, I know what's going on. In here, we use the data variable to simply printed its value. And let's save it on this. So OCR if you remember when we discussed it initially, it takes a lot of time because you're actually getting the data from an image and it is not going to be hundred percent reliable as well.

So that's always like a few drawbacks to use OCR but in case of image automations, that's the option we have. Right. Okay, and if we check the output activity, this is what it scraped. Am I add something something something wrong? Which doesn't look good because the actual data, if we see is it was the best of times it was the worst of times. It was the age of wisdom.

It was the age of foolishness. That's what is written in Google OCR is doing something else altogether. So let's try and use Microsoft OCR and see if that works. Right? I didn't know that myself, we have to play around and see the data quality and you can probably scale it up a little bit. I'll put the scale to three.

And let's get the same data everything is all good. The pod is running, trying to scrape the data from an image by locating it and you know, going through and pixel by pixel But it's trying to get some meaningful information out of that data in the image. So if we check the output, it was the best of times it was the worst of times, DMC instead of each signal seed was the age of wisdom, it was the ADC of foolishness. So you see, it is still a better output than the Google OCR. And, and if you want to have like the best data output, you got to play around with the parameters of the OCR engine that you're choosing to scrape the data. Right.

That's how the OCR activity to extract data with PDF document works. Both read PDF activities and like are actually standalone activities, meaning that they don't require containers or opened applications, right, and can execute independently, which means it supports the background processing. So like Excel, we need to have the Excel application scope to perform those extra, like the underlying activities. That's not the case with the PDF, right? You don't have to have the file visible or the application active, it can all be done via back end. Okay.

Then, other than these two activities, another way that is used to extract data from the PDF documents is through screen scraping. Right, the element from which data needs to be scraped is selected, and a preview of the extracted data is shown. Right and we can use the three output methods that we discussed before the full text native or OCR methods. And that's how it is going to look like let's say we have this file itself, which is the image one because getting the data through this, which is a selectable editable text, not editable, selectable text. It's pretty easy, the activities very reliable. But for images, it becomes a little challenging, right?

So let's say we take screen scraping wizard, and we select this as the whole PDF. Right? Nothing has been shown yet. If we go with the OCR and we refresh, let's see if we are able to point something out or not. And it was the best of time, it was the worst of time. It was the age of wisdom.

It was the age of foolishness with the dots. Everything has been read perfectly with the Google OCR with the scale too. So with images like this, it seems to be working fine. Right even let's say we want to try for the Microsoft OCR and let's put the scale to two and refresh to see if we are able to scrape the data or not. We still because, well, frankly, for this image. It is pretty readable.

But there may be cases when you know you might have to play around with invert. The scaling options or with the OCR choosing of the OCR engine as well to get your desired output, once you get that in the scrape result preview, you can finish it and correspondingly these sequences sequence of activities is generated where, you know, you have the get OCR text activity and with the Microsoft or the Google OCR engine, whichever you chose in the scraping wizard, and the text is also generated as the output variable. specific data extraction, there's a possibility there instead of extracting complete data from a PDF. only partial information is needed in our workflow. A quick example would be say to extract the total expense from an invoice the total amount rather than the complete invoice including trivial details like company name, ID, specific commodity or service charges, etc, etc.

You can extract same data across various PDF documents by using the same Activity if the PDF documents share the same layout structure, right, and to accomplish the data of specific, the task of specific direct interaction, the first activity we have is the get text activity. We've also used this before. So I'm going to walk through a quick example in here, the get text is gonna ask for the element where the data needs to be taken. And let's say we've taken this and we store the data in this data output variable. And we print the value in a message box. And if you run this, there's the data.

Right? Okay. Now, um, there may have been cases that you know, when you are working on a PDF document, and I also encountered this while working on a project that you know, none of the elements in a PDF are visible at all right? The whole PDF would be say, like taken as a one, one element itself, it was choosing one whole thing like if it was an image despite the fact that it is not an image. So for that, what you got to do is, first and foremost, use the Adobe Acrobat Reader because you'll be able to interact with the elements and in the Edit under the accessibility, go to Setup Assistant. And, you know, go through, like each and every screen that's gonna show like this wizard thing, and make sure that you have exactly the same settings that I have right now.

Because that's going to help you and there might be a few changes that you might need that can help you in you know, I am making your PDF elements are identifiable to the UiPath. Right? And once you save these settings, you can like, you know, for any PDF document, that's how it is going to remain so it's gonna work out. Right, this one, then, for large documents read only current visible pages. Yeah. And this one display PDF documents in a web browser can.

Okay, so get text activity was pretty straightforward. The other specific data extraction activity that we're going to talk about is anchor base. Anchor base is a major activity to extract data relative to other UI elements. Right, the relative element with respect to which data extraction happens is called an anchor. Let's see how an anchor base activity looks like. So here is the anchor and here's the sequence that needs all the operations that needs to be followed once the anchor condition is met.

So Say that usually, in the anchor, we use activities like find a major find element or something like that. Right? So we use the find element. And we have the PDF document in front of us. And suppose we want invoice number, right? So we find the element invoice number, or actually, let me not select that and indicate on screen invoice number, right?

And once the invoice number element is found, then we want to get the text relevant to it, which is the invoice number itself. Right? And we want to store the data in the data variable. This is what we've been using so far in this activity in this whole lecture, and we want to print the data as well. Okay. So now, once the invoice number, this element is found it's gonna get text from this from the Element Relative to the anchor position and then the data would be you know provided are we will get that in the workflow itself.

So let's run this and see if it works. Order Number, it's showing something else it's actually taking the order number which is down below the anchor point down below the invoice number, we're getting the order number, but we were supposed to get the invoice 3337 right. So, what could be the possible reason why it is wrong? We are selecting the correct element right? Yes, here is the anchor point as well. And once you select the anchor base, we have an anchor position input, which is going to tell us like relative to the anchor Where is are located where like, Where is the data element or actually the other way around.

So like, if you click on the left one, that means the data element is to the right of the invoice number or the invoice number is to the left of the data element, the anchor point is to the left is what the anchor position is suggesting. Right? Once you select the left, and you have selected the correct data element, then you have the same activity. Let's run this and see if it works. invoice 3337. Right.

So there always got to be you know, like always remember that your workflow might not work in the first row itself. And that's the case with any programming language as well. Right? You got to figure out what's the possible issue. See once we were getting the order Number, we knew that there's something wrong with the selection of the data extraction element by the workflow. So a few possible cases would have been that, you know, either there's some property issue, which was the case, or the selector would have been wrong, we actually checked in the activity itself that the selector or the element that we have chosen in the, in the sequence, which is next to the end here, with the highlight and everything, it showed that, you know, the element we have chosen, is seems correct.

You know, we could have also gone through it selected to see if it works or not, but yeah, it's just the text field. So, there isn't much in terms of the selector. So, anchor position or changing it, we're getting the correct data, and it's a very reliable activity. You are gonna use it pretty often in SAP automations in many many enterprise applications. Because you have a lot of fields, a lot of text inputs, clicking into small buttons, which are not even too far and us little wrong click in the little mismatched click in, you know, in a coordinate different from what was chosen initially could actually result in a, in a in a totally different operation altogether. Right.

So anchor point actually takes care of that and it's really, really very helpful in automating your big projects.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.