References

This is a quickstart reference to using PyPDFAnalyticsClient.

PDF Analytics Client

The PDF Analytics Client is a high level module that enables the verification of the images and text of a local PDF file.

class api_client.APIClient(token, url=u'https://pdf-analytics.com/api/')[source]

Main API client class

create_job(local_file, wait_to_complete=True)[source]

Create a PDF analysis job

Parameters:
  • local_file – the path of the local PDF file that needs to be uploaded to the server for the analysis
  • wait_to_complete – wait for the PDF analysis to complete. Default value is True.
Returns:

The JobClass object,

get_account_details()[source]

Get my account details

Returns:a dictionary object with the user’s account details { ‘max_pdf_size_mb’: 3, ‘daily_max_count’: 10, ‘today_remaining’: 4, }
get_job(job_id)[source]

Get PDF analysis job

Parameters:job_id – the PDF analysis job ID
Returns:The JobClass object,
class api_client.JobClass(id, client)[source]

Basic PDF analysis Job class

get_item(left, top, page, type=u'any')[source]

Get any item from the PDF (TODO: get figure)

Parameters:
  • left – Distance from the left of the page in points. Accepts single integer. e.g. 150
  • top – Distance from the top of the page in points. Accepts single integer. e.g 200
  • page – Number of page, e.g. 4
  • type – Type of the the item.
Returns:

A JSON object with the item’s information

get_metadata()[source]

Get the metadata of the PDF

Returns:A JSON object with the metadata of the PDF
get_status()[source]

Get the status of the PDF analysis

Returns:The analysis status as string. The string can be “In progress”, “Error” or “Complete”
Return type:str
verify_image(path, left, top, page, compare_method=u'pbp', tolerance=0.0)[source]

Verify a local image file exists in the PDF

Parameters:
  • path – The absolute or relative path of the locally stored image e.g. ‘/User/tester/apple.png’
  • left – Distance from the left of the page in points. Accepts single integer. e.g. 150
  • top – Distance from the top of the page in points. Accepts single integer. e.g 200
  • page – Number of page, e.g. an integer 4 or a string ‘all’, ‘last’, ‘1-4’
  • compare_method – Image comparison method
  • tolerance – Comparison tolerance. Default value 0.0. Example: 0.02
Returns:

If the request is successful it returns 200. If it is not successful it returns the error message.

Return type:

JSON

verify_pdf(path, excluded_areas=u'', tolerance=0.0)[source]

Verify a local PDF file with the uploaded job’s PDF

Parameters:
  • path – The absolute or relative path of the locally stored PDF ilfe e.g. ‘/User/tester/report.pdf’
  • excluded_areas – Excluded areas. List field. Example : [ {‘left’:146, ‘top’:452, ‘width’:97, ‘height’:13,’page’:2}, {‘left’: 414, ‘top’: 747, ‘width’: 45, ‘height’: 16, ‘page’: ‘all’},]
  • tolerance – Comparison tolerance. Default value 0.0. Example: 0.02
Returns:

If the request is successful it returns 200. If it is not successful it returns the error message.

Return type:

JSON

verify_text(text, left, top, page, method=u'contains')[source]

Verify a text exists in the PDF

Parameters:
  • text – The expected textural content. Accepts string. e.g. ‘This is the expected text’
  • left – Distance from the left of the page in points. Accepts single integer. e.g. 150
  • top – Distance from the top of the page in points. Accepts single integer. e.g 200
  • page – Number of page, e.g. an integer 4 or a string ‘all’, ‘last’, ‘1-4’
  • method – Text comparison method
Returns:

If the request is successful it returns 200. If it is not successful it returns the error message.

wait_analysis_to_complete()[source]

Wait for the PDF analysis to complete

After you submit the PDF to PDF Analytics website, the takes some seconds until it is ready to be used for verification.

Returns:If the analysis is completed and returns True else if in 20 seconds the job is not complete, returns False
Return type:bool