You are on page 1of 5

 Create a new Flowchart and name it as PDF Automation.

Add a sequence activity named as


Initialize and connect it with the start node

Create the following variables

 Double click the above sequence activity (Initialize) to expand. Add four assign activities and set
them as follows:
1. ACROBAT_EXE_PATH = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" (give the
path of your Acrobat Reader)
2. PDF_FOLDER = "./_inputs/pdf/"
3. PDF_FILES_WITH_TEMPLATE_ID = {({"T1","Invoice01.pdf"}),({"T2","Invoice02.pdf"})}
4. EXTRACTED_DATA_EXCEL_FILEPATH = "./_inputs/pdf/InvoiceExtractedData.xlsx"

 Go to the main Flowchart. Add a Build data table activity next to Initialize

 Double click the activity to expand. In the output section of the properties panel add
invoiceDataTable

 Create a Data Table as shown inside the activity


 Go back to main Flowchart and create a Foreach activity and name it as Process Each Invoice.
Double click the activity to expand

 Set Foreach item in PDF_FILES_WITH_TEMPLATE_ID

 In the body section add a Try catch activity. Inside the Try section add a sequence and name it as
Process Current Invoice

 Inside the above sequence add an Open Application activity and name it as Open application
'AcroRd32.exe <pdf_file>'. Indicate on the screen the application that is to be opened

 In the properties panel of this open application activity, add Arguments as " /n " +PDF_FOLDER
+item(1). File name as "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"

 Now add a sequence below this open application activity and name it as Invoice Processing

 Inside this sequence add Maximize Window activity. Below it add a Send hotkey activity, name it
as Zoom the PDF to 100%, check the ctrl box and set key as 1

 Add a Write Line activity and set text as "Processing... " +item(0) +" " +item(1)

 Add a Switch activity and name it as Invoice Cases, Set the Expression as item(0) and
TypeArgument as String

 Add a Close application activity and name it as Close application 'AcroRd32.exe Invoice01....' .
Indicate on the window the application that is to be closed

 In the Catches section add an exception as System.Exception. Inside this add a Log Message, set
Level as Error and Message as "Failed to process... " +item(0) +" " +item(1) +" -- "
+exception.Message

 Go back to the Invoice Cases and double click it to expand

 Expression was set to item(0). Add two new Cases as Case T1 and Case T2

 Click on T1. Add a Sequence inside it and name it as T1 Invoices. Double click it to expand
 Add a GetValue activity, to get the value of Invoice Number. Name this activity as Invoice
Number. Indicate on the screen the Invoice Number of Invoice 1 pdf. In the properties panel add
Value as invoiceNumber

 Similarly add another GetValue activity and name it as Invoice Date. Indicate on the screen the
Invoice Date. Set the Value in Properties panel as invoiceDate

 Add a Comment out activity. Inside this activity add a sequence and name it as Ignored Activities.
Add a Write Line activity inside it. Set the text as invoiceDate + " -- " +
invoiceDate.ToString.Split(":".ToCharArray)(0) +" -- " +
invoiceDate.ToString.Split(":".ToCharArray)(1)

 Add a GetValue activity to get the Suppliers Address. Set the name as Suppliers Address. Indicate
the Suppliers address on the Invoice 1. Set Value as supplierAddress in the properties panel

 Add an Anchor base activity. Inside this add a Find Image activity and set its name as Find Image
'AcroRd32.exe Invoice01....'. Add another activity as GetValue and name it as Get Text 'text
$40.00 USD', Set the value in the properties panel as invoiceAmount. Indicate on the screen the
grand total value of the bill

 Add an Add data row activity. In the properties panel add ArrayRow as
{supplierAddress.ToString.Split(Environment.NewLine.ToCharArray)(0), supplierAddress,
invoiceNumber.ToString.Split("#"c)(1), invoiceDate.ToString.Split(":"c)(1), invoiceAmount}. Set
DataTable as invoiceDataTable

 Go back to Invoice Cases > Case T2. Click to expand. Add a sequence and name it as T2 Invoices.
Add an AnchorBase activity and name it as Supplier Name (Anchor base)

 Add a Find Image activity and name it as Find Image 'AcroRd32.exe Invoice02....'. In its properties
panel set Accuracy as 0.8 and Target as Target. Image indicated on screen will be as shown in
below screenshot

 Add a GetValue activity and name it as Supplier Name. Indicate on the screen the name of the
Supplier. In the properties panel add value as supplierName

 Below the Anchor Base activity add a GetValue activity and name it as Invoice Number. Indicate
the Invoice# (invoice number) on the screen. In the properties panel add Value as invoiceNumber
 Now add a Comment out activity. Inside this add a Sequence and name it as Ignored Activities.
Inside this sequence add an Anchor base activity, double click to expand

 Inside the Anchor activity add a Find Image activity and name it as Find Image 'AcroRd32.exe
Invoice02....'. Select the image to be found as invoice#. In the properties panel add Accuracy as
0.8 and Target as Target.

 Also add a GetValue activity and indicate on the screen the corresponding Invoice number. In the
properties panel set Target as Target and Value as invoiceNumber

 Below the comment out activity add an Anchor base activity and name it as Invoice Date (Anchor
base). Inside it add a Find Image activity and name it as Find Image 'AcroRd32.exe Invoice02....'.
Set the properties panel as before. Again add a GetValue activity and name it as Get Text 'text
6/6/2016'. Set the Value in properties panel as invoiceDate

 Below this Anchor base add a GetValue activity and name it as Get Text 'text 123 Basedow Street'.
Set the Value as supplierAddress

 Add a GetValue activity and name it as Get Text 'text Leipzig, DE, 04277'. Select the corresponding
image on the screen. Set the Value as address2

 Add an assign activity and set it as supplierAddress = supplierAddress +", " +address2

 Add an anchor base activity. Inside it add a Find Image activity and name it as Find Image
'AcroRd32.exe Invoice02....'. Set the properties panel as before. Corresponding to it add a
GetValue activity and name it as Get Text 'text 5,500.00€'. Indicate the image on the screen
accordingly. Set the Value in the properties panel as invoiceAmount

 Add an Add data row activity. In the properties panel set ArrayRow as {supplierName,
supplierAddress, invoiceNumber, invoiceDate, invoiceAmount} and DataTable as
invoiceDataTable

 Go to the main Flowchart activity. Add a Write Range activity and name it as Save the Data in an
Excel. Double click the activity to expand
 In the properties panel set the DataTabel as invoiceDataTable, SheetName as "Sheet1",
StartingCell as "A1" and WorkbookPath as EXTRACTED_DATA_EXCEL_FILEPATH. Run the project

Then Your Assignment done.

You might also like