Python module to drive the awesome pdftk binary.
Proudly brought to you by the revolunet team
Fill a PDF with given data and returns the output PDF path
pdf_path: input PDFdatas: dictionnary of fielf names / valuesout_file(default=auto) : output PDF path. will use tempfile if not providedflatten(default=True) : flatten the final PDF
Merge multiple PDFs into one single file and returns the output PDF path
files: list of PDF files to concatenateout_file(default=auto) : output PDF path. will use tempfile if not provided
Split a single PDF in many pages and return a list of pages paths
pdf_path: input PDFout_dir(default=auto) : output PDFs dir. will use tempfile if not provided
warning if you give a out_dir parameter, ensure its empty, or the split function may destroy your files and return incorrect results.
Generate a XFDF file suited for filling PDF forms and return the generated XFDF file path
datas: dictionnary of datas
Return the number of pages for a given PDF
pdf_path: input PDF file
Fill a PDF model and add a cover page :
import pypdftk
datas = {
'firstname': 'Julien',
'company': 'revolunet',
'price': 42
}
generated_pdf = pypdftk.fill_form('/path/to/model.pdf', datas)
out_pdf = pypdftk.merge(['/path/to/cover.pdf', generated_pdf])This module is released under the permissive MIT license. Your contributions are always welcome.