Giter Site home page Giter Site logo

pdfpop's Introduction

Automate PDF population with pdfpop

License Release CI/CD Tests Codecov Size


Automate PDF population with pdfpop.

Installation

You can install pdfpop with:

pip install pdfpop

Usage

The pdfpop usage consists of two steps: (1) form configuration and (2) execution.

Step 1. Form Configuration

ℹ️ This step only needs to be run once for each unique form.

This step generates a form-specific configuration file that allows you to inform pdfpop how data should be routed from the data file to the PDF form. You can generate this file with the config command:

# Usage: pdfpop config <form>
pdfpop config examples/example-form.pdf

This will output a pdfpop- prefixed JSON file in your current working directory (e.g., pdfpop-example-form.json). By default, all fields will be assigned a value of null and, therefore, will be ignored until the null value is replaced with instructions on how to populate the field. An example of an edited configuration file is available here.

Step 2. Exectuion

Once you have a form configuration file you can populate your PDF form using the run command:

# Usage: pdfpop run <config> <data>
pdfpop run examples/example-form.json examples/example-data.xlsx

This will generate a populated PDF form at the location prescribed by the values of<output_dir>/<output_name> in the configuration file (e.g., examples/pdfpop-example-form.pdf).

License

Copyright (C) 2022 Ian Dinwoodie

pdfpop's People

Contributors

iandinwoodie avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

pdfpop's Issues

Simplify user interface

Overview

The current four command interface (i.e., add, list, remove, pop) is unnecessarily complicated, especially for the target user audience. We can simply the interface to just two commands, config and run, to accomplish the same goal with less complexity.

Proposed Interface

Config Command

  • Description: Generate a PDF form configuration file.
  • Usage: pdfpop config <form>
  • Behavior:
    • Error if <form> is not a valid path to a PDF form.
    • Write a configuration file for <form>.
      • Default output filename should be pdfpop-<name>.json where <name> is the base name of <form> less the extension.
      • Output file should be written to the current working directory.
      • Error if pdfpop-<name>.json already exists in the current working directory to avoid accidental overwrites.
      • Configuration file contents should be in JSON format containing:
        • I/O dictionary:
          • input: <form> where form is the actual file path given at creation.
        • Fields dictionary:
          • Key: PDF field
          • Value: null by default.

Run Command

  • Description: Populate a PDF form with data as prescribed by the configuration file.
  • Usage: pdfpop run <config> <data>.
  • Behavior:
    • Error if <map> is not a valid path to a configuration JSON file.
    • Error if <data> is not a valid path to a data file.
      • Support XLSX, XLS, and CSV data files.
    • Error when a PDF field is encountered that does not exist in the configuration's fields dictionary.
    • Write a populated copy of <form>.
      • Default output filename should be <name>.pdf where <name> is the base name of <config> less the extension.
      • Output a summary of the actions taken so that the configuration and output can be iteratively adjusted without the need to open the populated PDF form to verify.

Allow execution of I/O configuration values

Values for the key-value pairs in the io section of the configuration should be executable for runtime determinism. For example, users should be able to prescribe an output filename based on information from the data file (e.g., <first>-<last>.pdf).

Add attributions

Attributions need to be added for:

  • PDF form filling logic
  • Popsicle SVG
  • Banner font

Add system tests

Application should be system tested in addition to unit tested.

No need to have return statement in IO config.

Currently the IO config entries include return which is unnecessary since they are just returning a value. Instead, we can just use the value.

Old behavior:

"io": {
    "form": "return 'form.pdf'"

New behavior:

"io": {
    "form": "form.pdf"

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.