Checking a payslip

In this article we will demonstrate how the PDFAnalytics web service can be used to verify automatically the content of a payslip PDF file.

We will use the PyPI library python-pdf-analytics-client which allows to automate the most common functions of the PDFAnalytics service.  The test cases will be written by using the python behave library.

The demo payslip PDF file is located inside the GitHub repository .

        1. The payslip document is located inside the GitHub repository 
        2. Get an account on PDFAnalytics and log in
        3. From the PDFAnalytics, upload the payslip to start the inspection as show belowupload_pdf
        4. Check the coordinates on where the expected text boxes are located inspector
        5. Create a directory for your behave_payslip
          $ mkdir ~/behave_payslip
        6. Setup a virtualenv python environment from the
          $ cd ~/behave_payslip
          $ virtualenv venv
          $ source venv/bin/activate
          $ pip install python-pdf-analytics-client
        7. Create the python behave file structure
          • : to run your environmental code
          • : the PDF payslip document
          • features/ : to store your feature test steps
          • steps/ : to store your python test steps
          • steps/, to store the actual test steps. For the test steps you can reuse (i.e. copy ) the definitions from the file on Github
        8. Create your feature file at features/payslip_pdf.feature . Check the example below to get an idea :
           Scenario: Verify payments and logo
           Given the pdf file "payslip.pdf" is sent to be analysed
           Then I "can" see the image "payslip_logo.png", at [left, top] ["100", "100"] on page "1" in pdf
           And I read "Total gross <br>payments:", at [left, top] ["74", "599"] on page "1" in pdf
           And I read "£1021.43", at [left, top] ["160", "584"] on page "1" in pdf
           And I read "Total <br>deductions:", at [left, top] ["250", "603"] on page "1" in pdf
           And I read "£304.92", at [left, top] ["334", "587"] on page "1" in pdf
           And I read "Net pay:", at [left, top] ["430", "570"] on page "1" in pdf
           And I read "£716.51", at [left, top] ["516", "586"] on page "1" in pdf
        9. Run you behave test cases from the command line:
          $ behave -D token=|your-personal-token-ID-from-the-PDFAnalytics-site|
        10. Done !


You have find a copy of this code at the Github/examples .

If you have any questions do not hesitate to contact us.