High-level Interface

High-level library functions to inspect and fill pdf fillable forms. These functions provide an programmatic interface similar to the command-line interface.

Note

These functions return a generator.

If you don’t iterate the results, they won’t do anything.

pdfforms.inspect_pdfs(pdf_files, field_defs_file='fields.json', prefix='test/')

inspect pdf for fillable form fields

This is essentially the same as pdfforms inspect command.

Parameters
  • pdf_files (Iterable[str]) – file paths to inspect

  • field_defs_file (str) – path to which to save json field definitions

  • prefix (str) – prefix for saving test files

Returns

a generator of inspected file names. Be sure to iterate it or nothing will happen.

Return type

Iterator[str]

pdfforms.fill_pdfs(data_file, sheet_name=None, pyexcel_library=None, field_defs_file='fields.json', prefix='filled/', no_flatten=False, value_transforms=None)

fill pdf forms with data from a spreadsheet

This is essentially the same as pdfforms fill command.

Parameters
  • data_file (str) – path of spreadsheet datafile

  • sheet_name (Optional[str]) – sheet name, defaults to first sheet

  • field_defs_file (str) – path from which to load json field definitions

  • prefix (str) – prefix for saving filled pdf files

  • no_flatten (bool) – do not flatten output pdf files

  • value_transforms (Optional[Iterable[Callable]]) – value transformation/format functions to be called in order on each data value before inserting it into the pdf form. See api example for more information.

  • pyexcel_library (Optional[str]) –

Returns

a generator of filled form file names. Be sure to iterate it or nothing will happen.

Return type

Iterator[str]