Challenge 13

There is a challenge which I’m currently looking at

The idea is that you open a pdf document and then go through several lines in the document working out which of 3 check boxes have been ticked in each row.

To give an indication of row position I look for a text string found in each row.

I use that as a starting point to generate a region (this is where it is going wrong I think) that I want to search for the tick box (My method the region doesn’t seem to be changing so I always pick the same tick box, when that bit is working). I assign a region to check (the size of the box should be the same each time it’s only the Y position that should change)

CheckBoxesRegion = New UiPath.Core.Region(New Rectangle(103, Y, 309, 38))

The problem is that I then want to Find Image but only look in that CheckBoxesRegion.

The result from the find image does not change, it doesn’t loop through all the rows. I’ve stepped through the code but can’t see why it quits the loop

If anyone can see what I’m doing wrong here it would be appreciated.

My code is here

Chall13_PDFScraping.zip (415.5 KB)

Many thanks,

I have a feeling that what is happening is that when the PDF is opened it opens up BIG and only 2 lines of the data that I am interested in are showing. I think this may be causing some of my problems in that maybe only the shown region is capable of being searched. Anyway will look into it.

OK that didn’t help, but I’ll keep the click ‘Fit on one page’ button in the code so I can see the whole pdf while the code is running.

Chall13_PDFScraping.zip (415.9 KB)

What I’d like to do is use the Highlight activity to show the region that I’m searching for the tick box (when debugging) but I think that the highlight activity just accepts an element and I have a region (It has a clipping region property but I’m not sure how that works as if I put values in the left top right and bottom text boxes they disappear when I go back to the activity)

Just updating this in the hope that someone will look at it and offer a suggestion.

The first thing I want to do is in a screen shot image of a front end system (to mimic citrix) is to find all the occurences of a particular image (using Find image matches) then using the position of each of the images offset their location and resize it to search for another image, relative to the first (I only want to search for the second image in this offsetted region).

Can this be done?

FindSelectedCheckbox.xaml (9.3 KB)

Open your pdf with zoom in to 125% and run attached sample, it will highlight all checked boxes. If it can help you to move forward.

Firstly thank you very much @muhammad.hanif for looking at this problem.

Your suggestion is to use find image matches to find all the occurrences of the tick box and then use a for each loop on the results.

I did consider this approach but this means that you miss any row that doesn’t have a ticked tick box (which I don’t want to do). So what I did (in my not working solution) was to find something that was in every row (in my case search for the image of the word VERIFY as in every row) I then wanted to use the position of that word as a starting point to resize and offset a region to search for the ticked tick box in that row. If I didn’t find a ‘ticked’ tick box in that region I knew it was unticked for that row and I could give it a value of N/A (just looking for ticked tick boxes at the start means you miss those rows). If I did find a ticked tick box I could use it’s position to determine what value it was. Either way I want to search for the UNIT NUMBER (if there is one on the line I am searching) so I need to be able to set a search region for that too.

Chall13_PDFScraping.zip (415.9 KB)

Unrelated to the search region problem when you do a ‘find image matches’ the resulting array of matches are not always in the same order as they appear in the document. What you could do in that case is store the data that you are interested in along with the Y coordinate of the image that you are searching for and then sort the resulting table by the Y coordinate value (if you need the results in the right order). I haven’t investigated sorting the table issue yet.

This post covers sorting a data table (not my main problem but at least this will help when it does work)

Charlie, but are you using exactly this same pdf documents, I think that I might have something developed for it, I’ll upload the solution later on.

regards,

Thanks @Beepsheep. I saw your design on the challenges section (and that was a great working solution, whereas mine is a non working, not solution) before I started mine but your solution text scraped the entire area using chrome and I wanted to get my solution to work using a search range for the tick boxes based on the position of another item. It was more a question of getting that method to work rather than solving the actual challenge.