diff options
author | Teddy Wing | 2021-04-11 03:48:02 +0200 |
---|---|---|
committer | Teddy Wing | 2021-04-11 03:48:02 +0200 |
commit | 8102f48b5aaf6965a37814c55f728711382661f2 (patch) | |
tree | ea7b8f9c3365d5f9cf6a494081dccd1e02aa3e07 /src/main.rs | |
parent | 28c232ded4313effdeeef18f746688df391ab2fb (diff) | |
download | formurapid-8102f48b5aaf6965a37814c55f728711382661f2.tar.bz2 |
Fill in the form's fields with the fields' IDs
Use a copy of Form 1040 as a sample. A copy of the PDF is produced so
you can reference the text fields by their ID.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index e7a11a9..2713df4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,15 @@ +use pdf_forms::{Form, FieldType}; + fn main() { - println!("Hello, world!"); + let mut form = Form::load("./f1040.pdf").unwrap(); + + for i in 0..form.len() { + let field_type = form.get_type(i); + + if let FieldType::Text = field_type { + form.set_text(i, format!("{}", i)).unwrap(); + } + } + + form.save("./f1040-new.pdf").unwrap(); } |