Skip to content

Example code for python 3.6 is not working on macOS 10.13.1 #9

@Twirl1910

Description

@Twirl1910

I always get the error-code:

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pdfjinja.py", line 208, in exec_pdftk
p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 707, in init
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1326, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'pdftk'

I installed pdftk (even version 2.02 from here jkraemer/pdf-forms#30) and used the example code in python:

import os

from pdfjinja import PdfJinja
import pypdftk

dirname = os.path.dirname(file)
template_pdf_file = os.path.join(dirname, 'sample.pdf')
template_pdf = PdfJinja(template_pdf_file)

rendered_pdf = template_pdf({
'firstName': 'Faye',
'lastName': 'Valentine',
'address': {
'street': '223B Baker Street',
'apt': '6F',
'city': 'London',
'zipcode': 94455
},
'sig': os.path.join(dirname, 'sig.png'),
'spirit': 'Panda',
'evil': True,
'language': {
'english': True
},
'attachments': [{
'data': os.path.join(dirname, 'attachment.png'),
'text': 'Tux\nFriendly Penguin\nMascot :)',
'dimensions': [100, 200, 400, 400]
}]
})

output_file = os.path.join(dirname, 'output.pdf')
rendered_pdf.write(open(output_file, 'wb'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions