xfdfgen is a Python library for creating xfdf files that can be used to populate pdf form fields.
Project description
xfdfgen
xfdfgen is a Python library for creating xfdf files that can be used to populate pdf form fields.
Installation
Use the package manager pip to install xfdfgen.
pip install xfdfgen
Usage
from xfdfgen import Xfdf
pdf_document_name = 'example_document.pdf'
dictionary_of_fields= {
'first_name': 'foo',
'last_name': 'bar'
}
document = Xfdf(pdf_document_name, dictionary_of_fields)
output_path = 'example_out.xfdf'
document.write_xfdf(output_path)
pdf_document_name should match the name of the document containing the form fields you want to fill in.
The keys of the dictionary_of_fields are the form field ids in the document. To find them, you can use Adobe Acrobat, pdftk, or PDFescape if you don't want to install anything.
The output can be imported with various programs/libraries, such as pdftk, Foxit Reader, Adobe Acrobat, and pypdftk.
Alternatively, you can use pdfformfields which this package was created for. pdfformfields is capable of reading in the metadata of the pdf and filling in the form for you.
To view the xfdf file in a more human readable format, use
document.pretty_print()
which should output
<?xml version="1.0" ?>
<xfdf xml:space="preserve" xmlns="http://ns.adobe.com/xfdf/">
<f href="example_pdf.pdf"/>
<fields>
<field name="first_name">
<value>foo</value>
</field>
<field name="last_name">
<value>bar</value>
</field>
</fields>
</xfdf>
An example is included in the example folder.
Compatibility
This package has been tested on Windows 10 using Python 3.7
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xfdfgen-0.4.tar.gz.
File metadata
- Download URL: xfdfgen-0.4.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3a823a1df79d9ebce45e359ef59cdca3eb6b8fbf506ff62a1938937fcac2a90
|
|
| MD5 |
a93b29447aa56257495b16ba04944c13
|
|
| BLAKE2b-256 |
19cd78fef3c8ad9de7bb0155aa0f24185a367706514b5f16c680a6069075005d
|
File details
Details for the file xfdfgen-0.4-py3-none-any.whl.
File metadata
- Download URL: xfdfgen-0.4-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1957f973a8d3767713004a0270308adcacfef813d6727d22f151b21ef37a443a
|
|
| MD5 |
dc864c7b36e5e50de985bf027a03af84
|
|
| BLAKE2b-256 |
68a55797da943a4b896cc0033fc4c9c1da5fd4b3ec73fb46f5fb2b9787f37ec4
|