예제 #1
0
 def test_fill_form(self):
     result = pypdftk.fill_form(TEST_XPDF_PATH,
                                datas=SAMPLE_DATA2,
                                flatten=False)
     result_data = ordered(pypdftk.dump_data_fields(result))
     expected_data = ordered(json.loads(read(TEST_XPDF_FILLED_DATA_DUMP)))
     self.assertEqual(result_data, expected_data)
예제 #2
0
파일: app.py 프로젝트: benlayton/pdf-filler
def get_dump_data_fields(pdfname):
    """
    Get dumped fields for specified pdfname. Can be formatted.

    GET: /pdf/<pdfname>?format={pairs,keys}
    :pairs - list of pairs (key: value) for dumped data fields
    :keys - only dumped field names
    """
    data = pypdftk.dump_data_fields("{folder}/{file}.pdf".format(
        folder=PDF_FOLDER, file=pdfname))

    formated = request.args.get('format')
    if "pairs" == formated:
        data = format_fields_by_pairs(data)
    elif "keys" == formated:
        data = format_fields_by_keys(data)

    return jsonify(data)
예제 #3
0
def generate_form(datas):
    module_dir = os.path.dirname(__file__)  # get current directory
    PATH = os.path.join(module_dir, "SOFC-Credit-Card-Payment.pdf")
    var = py.dump_data_fields(PATH)
    # for elem in var:
    # 	print(elem['FieldName'])
    generated_pdf = py.fill_form(PATH,
                                 datas,
                                 out_file=os.path.join(module_dir,
                                                       'new_pdf.pdf'))
    print('form has been generated')
    return os.path.join(module_dir, 'new_pdf.pdf')


# datas = dict()
# datas['Account Number'] = 123456
# datas['SubAccount']		= 123456
# datas['Amount'] 		= 123
# datas['Date'] 			= date
# datas['Org Name'] 		= org
# generate_form(datas)

# Account Number
# SubAccount
# Date mmddyyyy
# Amount
# Vendor
# Contact
# Phone
# Reservation Phone
# Reservation Guest
# Reservation by
# Start Date
# End Date
# Statement of Benefit
# Leader Phone
# Leader Date
# Advisor Phone
# Advisor Date
# Travel 1
# Travel 2
# Org Name
# Invoice Confirmation
예제 #4
0
 def test_dump_data_fields(self):
     result_data = ordered(pypdftk.dump_data_fields(TEST_XPDF_PATH))
     expected_data = ordered(json.loads(read(TEST_XPDF_DATA_DUMP)))
     self.assertEqual(result_data, expected_data)
예제 #5
0
 def test_dump_data_fields(self):
     result_data = ordered(pypdftk.dump_data_fields(TEST_XPDF_PATH))
     expected_data = ordered(json.loads(read(TEST_XPDF_DATA_DUMP)))
     self.assertCountEqual(list(result_data),
                           [dict(i) for i in expected_data])
예제 #6
0
파일: test.py 프로젝트: revolunet/pypdftk
 def test_dump_data_fields(self):
     result_data = ordered(pypdftk.dump_data_fields(TEST_XPDF_PATH))
     expected_data = ordered(json.loads(read(TEST_XPDF_DATA_DUMP)))
     self.assertEqual(result_data, expected_data)
예제 #7
0
파일: test.py 프로젝트: revolunet/pypdftk
 def test_fill_form(self):
     result = pypdftk.fill_form(TEST_XPDF_PATH, datas=SAMPLE_DATA2, flatten=False)
     result_data = ordered(pypdftk.dump_data_fields(result))
     expected_data = ordered(json.loads(read(TEST_XPDF_FILLED_DATA_DUMP)))
     self.assertEqual(result_data, expected_data)