Skip to main content

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

Apache License 2.0

Metadata

Release files for xfdfgen 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xfdfgen 0.4
File Size Uploaded
xfdfgen-0.4.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xfdfgen 0.4
File Interpreter ABI Platform
xfdfgen-0.4-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / xfdfgen-0.4.tar.gz

Download URL xfdfgen-0.4.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f3a823a1df79d9ebce45e359ef59cdca3eb6b8fbf506ff62a1938937fcac2a90
BLAKE2b-256 checksum
How to use checksums
19cd78fef3c8ad9de7bb0155aa0f24185a367706514b5f16c680a6069075005d
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / xfdfgen-0.4-py3-none-any.whl

Download URL xfdfgen-0.4-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1957f973a8d3767713004a0270308adcacfef813d6727d22f151b21ef37a443a
BLAKE2b-256 checksum
How to use checksums
68a55797da943a4b896cc0033fc4c9c1da5fd4b3ec73fb46f5fb2b9787f37ec4
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.4 This release

2 release files

0.3

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page