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.03
List Price:  €133.05
You save:  €38.01
£79.15
List Price:  £110.82
You save:  £31.66
CA$139.67
List Price:  CA$195.55
You save:  CA$55.87
A$153.55
List Price:  A$214.98
You save:  A$61.42
S$134.39
List Price:  S$188.16
You save:  S$53.76
HK$778.22
List Price:  HK$1,089.54
You save:  HK$311.32
CHF 88.36
List Price:  CHF 123.71
You save:  CHF 35.34
NOK kr1,105.21
List Price:  NOK kr1,547.34
You save:  NOK kr442.12
DKK kr708.87
List Price:  DKK kr992.45
You save:  DKK kr283.57
NZ$170.45
List Price:  NZ$238.64
You save:  NZ$68.18
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳11,959.01
List Price:  ৳16,743.10
You save:  ৳4,784.08
₹8,452.40
List Price:  ₹11,833.70
You save:  ₹3,381.29
RM446.45
List Price:  RM625.05
You save:  RM178.60
₦168,042.19
List Price:  ₦235,265.79
You save:  ₦67,223.60
₨27,819.88
List Price:  ₨38,948.94
You save:  ₨11,129.06
฿3,466.55
List Price:  ฿4,853.31
You save:  ฿1,386.76
₺3,454.83
List Price:  ₺4,836.90
You save:  ₺1,382.07
B$580.99
List Price:  B$813.41
You save:  B$232.42
R1,812.36
List Price:  R2,537.39
You save:  R725.02
Лв185.85
List Price:  Лв260.20
You save:  Лв74.35
₩140,106.88
List Price:  ₩196,155.24
You save:  ₩56,048.35
₪373.41
List Price:  ₪522.79
You save:  ₪149.38
₱5,905.80
List Price:  ₱8,268.36
You save:  ₱2,362.56
¥15,438.71
List Price:  ¥21,614.81
You save:  ¥6,176.10
MX$2,034.25
List Price:  MX$2,848.03
You save:  MX$813.78
QR364.93
List Price:  QR510.92
You save:  QR145.98
P1,367.12
List Price:  P1,914.02
You save:  P546.90
KSh12,923.70
List Price:  KSh18,093.70
You save:  KSh5,170
E£4,964.56
List Price:  E£6,950.58
You save:  E£1,986.02
ብር12,476.97
List Price:  ብር17,468.25
You save:  ብር4,991.28
Kz91,223.61
List Price:  Kz127,716.70
You save:  Kz36,493.09
CLP$97,372.26
List Price:  CLP$136,325.06
You save:  CLP$38,952.80
CN¥724.09
List Price:  CN¥1,013.76
You save:  CN¥289.66
RD$6,035.83
List Price:  RD$8,450.41
You save:  RD$2,414.57
DA13,357.64
List Price:  DA18,701.23
You save:  DA5,343.59
FJ$226.99
List Price:  FJ$317.80
You save:  FJ$90.80
Q772.55
List Price:  Q1,081.60
You save:  Q309.05
GY$20,937.04
List Price:  GY$29,312.70
You save:  GY$8,375.65
ISK kr13,828.61
List Price:  ISK kr19,360.61
You save:  ISK kr5,532
DH999.72
List Price:  DH1,399.66
You save:  DH399.93
L1,820.82
List Price:  L2,549.22
You save:  L728.40
ден5,848.08
List Price:  ден8,187.54
You save:  ден2,339.46
MOP$802.33
List Price:  MOP$1,123.29
You save:  MOP$320.96
N$1,815.10
List Price:  N$2,541.22
You save:  N$726.11
C$3,682.57
List Price:  C$5,155.75
You save:  C$1,473.17
रु13,507.81
List Price:  रु18,911.48
You save:  रु5,403.66
S/379.77
List Price:  S/531.69
You save:  S/151.92
K402.86
List Price:  K564.02
You save:  K161.16
SAR375.38
List Price:  SAR525.55
You save:  SAR150.16
ZK2,769.51
List Price:  ZK3,877.43
You save:  ZK1,107.91
L472.94
List Price:  L662.13
You save:  L189.19
Kč2,407.85
List Price:  Kč3,371.09
You save:  Kč963.24
Ft39,078.98
List Price:  Ft54,712.13
You save:  Ft15,633.15
SEK kr1,102.90
List Price:  SEK kr1,544.10
You save:  SEK kr441.20
ARS$100,263.16
List Price:  ARS$140,372.43
You save:  ARS$40,109.27
Bs693
List Price:  Bs970.23
You save:  Bs277.22
COP$441,313.30
List Price:  COP$617,856.28
You save:  COP$176,542.97
₡50,820.06
List Price:  ₡71,150.12
You save:  ₡20,330.05
L2,528.86
List Price:  L3,540.51
You save:  L1,011.64
₲783,733.33
List Price:  ₲1,097,258.01
You save:  ₲313,524.68
$U4,278.05
List Price:  $U5,989.44
You save:  $U1,711.39
zł413.19
List Price:  zł578.49
You save:  zł165.29
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.