Code Monkey home page Code Monkey logo

fdfgen's Introduction

fdfgen

Build Status

Python port of the PHP forge_fdf library by Sid Steward

PDF forms work with FDF data. I ported a PHP FDF library to Python a while back when I had to do this and released it as fdfgen. I use that to generate an fdf file with the data for the form, then use pdftk to push the fdf into a PDF form and generate the output.

QUICK INSTALL

pip install fdfgen

HOW IT WORKS

  1. You (or a designer) design the form.pdf in Acrobat.

  2. Mark the form fields and take note of the field names. This can be done either through Acrobat or by installing pdftk and entering the command line

     pdftk [pdf name] dump_data_fields
    
  3. Let's say your form has fields "name" and "telephone".

    Use fdfgen to create a FDF file:

     #!/usr/bin/env python
     from fdfgen import forge_fdf
     
     fields = [('name', 'John Smith'), ('telephone', '555-1234')]
     fdf = forge_fdf("",fields,[],[],[])
     
     with open("data.fdf", "wb") as fdf_file:
         fdf_file.write(fdf)
    
  4. Then you run pdftk to merge and flatten:

    pdftk form.pdf fill_form data.fdf output output.pdf flatten
    

    and a filled out, flattened (meaning that there are no longer editable form fields) pdf will be in output.pdf.

CHANGELOG

  • 0.16.1 -- 2017-11-21 -- Fix TypeError in python 3.6 by Tom Grundy (@caver456)
  • 0.16.0 -- 2017-02-22 -- Allow for different values for each checkbox by [email protected]
  • 0.15.0 -- 2016-09-23 -- Encode field names as UTF-16 fix by Andreas Pelme [email protected]
  • 0.14.0 -- 2016-08-09 -- Adobe FDF Compatibility added by Cooper Stimson (@6C1)
  • 0.13.0 -- 2016-04-22 -- python 3 bugfix from Julien Enselme [email protected]
  • 0.12.1 -- 2015-11-01 -- handle alternative checkbox values fix from Bil Bas https://github.com/Spooner
  • 0.12.0 -- 2015-07-29 -- python 3 bugfixes
  • 0.11.0 -- 2013-12-07 -- python 3 port from Evan Fredericksen
  • 0.10.2 -- 2013-06-16 -- minor code refactor and added command line options from Robert Stewart https://github.com/rwjs
  • 0.10.1 -- 2013-04-22 -- unbalanced paren bugfix from Brandon Rhodes [email protected]
  • 0.10.0 -- 2012-06-14 -- support checkbox fields and parenthesis in strings from Guangcong Luo [email protected]
  • 0.9.2 -- 2011-01-12 -- merged unicode fix from Sébastien Fievet [email protected]

RUNNING TESTS:

  • Create a virtual environment
  • tox is required to run the tests. You can install the correct version with pip install -r requirements-tests.txt
  • Run tox to run tests for all Python versions.
  • To run a specific test and specific Python versions, you may use tox -e py27 -- tests/test_encoding.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.