#pdf #field #forms

pdf_forms

A library for programatically filling out pdf forms

10 releases

0.3.4 Oct 3, 2020
0.3.3 Sep 29, 2020
0.2.3 Sep 26, 2020
0.1.0 Sep 23, 2020

#1937 in Text processing

Download history 8/week @ 2024-07-13 1/week @ 2024-07-20 56/week @ 2024-07-27 1/week @ 2024-08-03 22/week @ 2024-09-21 7/week @ 2024-09-28

59 downloads per month

MIT license

36KB
720 lines

Fill PDF Forms

A library to programatically identify and fill out PDF forms.

WARNING: This is a fork of the original "pdf_form" crate made by jsandler18, including all improvements made by malte-v.

Example Code

Read a PDF and discover the form fields

extern crate pdf_form;
use pdf_form::{Form, FieldType};

// Load the pdf into a form from a path
let form = Form::load("path/to/pdf").unwrap();
// Get all types of the form fields (e.g. Text, Radio, etc) in a Vector
let field_types = form.get_all_types();
// Print the types
for type in field_types {
    println!("{:?}", type);
};

Write to the form fields

extern crate pdf_form;
use pdf_form::{Form, FieldState};

// Load the pdf into a form from a path
let mut form = Form::load("path/to/pdf").unwrap();
form.set_text(0, String::from("filling the field"));
form.save("path/to/new/pdf");

Dependencies

~17MB
~171K SLoC