From d027a1401f32f2f5a3c37860fb3c9524b594f9dd Mon Sep 17 00:00:00 2001 From: Emulator000 Date: Sat, 26 Sep 2020 20:59:41 +0200 Subject: Basic appearance regeneration for altered form text fields --- src/lib.rs | 185 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- src/utils.rs | 23 ++++++++ 2 files changed, 187 insertions(+), 21 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 59c36f9..b7cc588 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,7 @@ use std::str; use bitflags::_core::str::from_utf8; +use lopdf::content::{Content, Operation}; use lopdf::{Document, Object, ObjectId, StringFormat}; use crate::utils::*; @@ -135,18 +136,31 @@ impl Form { Self::load_doc(doc) } - fn load_doc(doc: Document) -> Result { + fn load_doc(mut doc: Document) -> Result { let mut form_ids = Vec::new(); let mut queue = VecDeque::new(); // Block so borrow of doc ends before doc is moved into the result { - // Get the form's top level fields - let catalog = doc.trailer.get(b"Root")?.deref(&doc)?.as_dict()?; - let acroform = catalog.get(b"AcroForm")?.deref(&doc)?.as_dict()?; - let fields_list = acroform - .get(b"Fields")? - // .deref(&doc)? - .as_array()?; + doc.decompress(); + + let acroform = doc + .objects + .get_mut( + &doc.trailer + .get(b"Root")? + .deref(&doc)? + .as_dict()? + .get(b"AcroForm")? + .as_reference()?, + ) + .ok_or(LoadError::NotAReference)? + .as_dict_mut()?; + + // Sets the NeedAppearances option to true into "AcroForm" in order + // to render fields correctly + // acroform.set("NeedAppearances", Object::Boolean(true)); + + let fields_list = acroform.get(b"Fields")?.as_array()?; queue.append(&mut VecDeque::from(fields_list.clone())); // Iterate over the fields @@ -423,8 +437,10 @@ impl Form { .as_dict_mut() .unwrap(); - field.set("V", Object::String(s.into_bytes(), StringFormat::Literal)); - field.remove(b"AP"); + field.set("V", Object::string_literal(s.into_bytes())); + + // Regenerate text appearance confoming the new text but ignore the result + let _ = self.regenerate_text_appearance(n); Ok(()) } @@ -432,6 +448,137 @@ impl Form { } } + /// Regenerates the appearance for the field at index `n` due to an alteration of the + /// original TextField value, the AP will be updated accordingly. + /// + /// # Incomplete + /// This function is not exhaustive as not parse the original TextField orientation + /// or the text alignment and other kind of enrichments, also doesn't discover for + /// the global document DA. + /// + /// A more sophisticated parser is needed here + fn regenerate_text_appearance(&mut self, n: usize) -> Result<(), lopdf::Error> { + let field = { + self.doc + .objects + .get(&self.form_ids[n]) + .unwrap() + .as_dict() + .unwrap() + }; + + // The value of the object (should be a string) + let value = field.get(b"V")?.to_owned(); + + // The default appearance of the object (should be a string) + let da = field.get(b"DA")?.to_owned(); + + // The default appearance of the object (should be a string) + let rect = field + .get(b"Rect")? + .as_array()? + .iter() + .map(|object| { + object + .as_f64() + .unwrap_or(object.as_i64().unwrap_or(0) as f64) + }) + .collect::>(); + + // Gets the object stream + let object_id = field.get(b"AP")?.as_dict()?.get(b"N")?.as_reference()?; + let stream = self.doc.get_object_mut(object_id)?.as_stream_mut()?; + + // Decode and get the content, even if is compressed + let mut content = { + if let Ok(content) = stream.decompressed_content() { + Content::decode(&content)? + } else { + Content::decode(&stream.content)? + } + }; + + // Ignored operators + let ignored_operators = vec![ + "bt", "tc", "tw", "tz", "g", "tr", "tf", "tj", "et", "q", "bmc", "emc", + ]; + + // Remove these ignored operators as we have to generate the text and fonts again + content.operations.retain(|operation| { + !ignored_operators.contains(&operation.operator.to_lowercase().as_str()) + }); + + // Let's construct the text widget + content.operations.append(&mut vec![ + Operation::new("BMC", vec!["Tx".into()]), + Operation::new("q", vec![]), + Operation::new("BT", vec![]), + ]); + + // The default font object (/Helv 12 Tf 0 g) + let default_font = ("Helv", 12, 0, "g"); + + // Build the font basing on the default appearance, if exists, if not, + // assume a default font (surely to be improved!) + let font = match da { + Object::String(ref bytes, _) => { + let values = from_utf8(bytes)? + .trim_start_matches('/') + .split(' ') + .collect::>(); + + if values.len() != 5 { + default_font + } else { + ( + values[0], + values[1].parse::().unwrap_or(0), + values[3].parse::().unwrap_or(0), + values[4], + ) + } + } + _ => default_font, + }; + + // Define some helping font variables + let font_name = font.0; + let font_size = font.1; + let font_color = (font.2, font.3); + + // Set the font type and size and color + content.operations.append(&mut vec![ + Operation::new("Tf", vec![font_name.into(), font_size.into()]), + Operation::new(font_color.1, vec![font_color.0.into()]), + ]); + + // Calcolate the text offset + let x = 3.0; // Suppose this fixed offset as we should have known the border here + let y = 0.5 * (rect[3] - rect[1]) - 0.4 * font_size as f64; // Formula picked up from Poppler + + // Set the text bounds, first are fixed at "1 0 0 1" and then the calculated x,y + content.operations.append(&mut vec![Operation::new( + "Tm", + vec![1.into(), 0.into(), 0.into(), 1.into(), x.into(), y.into()], + )]); + + // Set the text value and some finalizing operations + content.operations.append(&mut vec![ + Operation::new("Tj", vec![value]), + Operation::new("ET", vec![]), + Operation::new("Q", vec![]), + Operation::new("EMC", vec![]), + ]); + + // Set the new content to the original stream and compress it + if let Ok(encoded_content) = content.encode() { + stream.set_plain_content(encoded_content); + let _ = stream.compress(); + } + + Ok(()) + } + /// If the field at index `n` is a checkbox field, toggles the check box based on the value /// `is_checked`. /// If it is not a checkbox field, returns ValueError @@ -441,17 +588,6 @@ impl Form { pub fn set_check_box(&mut self, n: usize, is_checked: bool) -> Result<(), ValueError> { match self.get_state(n) { FieldState::CheckBox { .. } => { - let state = Object::Name( - { - if is_checked { - "Yes" - } else { - "Off" - } - } - .to_owned() - .into_bytes(), - ); let field = self .doc .objects @@ -460,6 +596,13 @@ impl Form { .as_dict_mut() .unwrap(); + let on = get_on_value(field); + let state = Object::Name( + if is_checked { on.as_str() } else { "Off" } + .to_owned() + .into_bytes(), + ); + field.set("V", state.clone()); field.set("AS", state); diff --git a/src/utils.rs b/src/utils.rs index 7ff4e41..12db115 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,5 +1,7 @@ use lopdf::{Dictionary, Object}; +use crate::from_utf8; + bitflags! { pub struct FieldFlags: u32 { const READONLY = 0x1; @@ -47,3 +49,24 @@ pub fn get_field_flags(field: &Dictionary) -> u32 { .as_i64() .unwrap() as u32 } + +pub fn get_on_value(field: &Dictionary) -> String { + let mut option = None; + if let Ok(ap) = field.get(b"AP") { + if let Ok(dict) = ap.as_dict() { + if let Ok(values) = dict.get(b"N") { + if let Ok(options) = values.as_dict() { + for (name, _) in options { + if let Ok(name) = from_utf8(name) { + if name != "Off" && option.is_none() { + option = Some(name.into()); + } + } + } + } + } + } + } + + option.unwrap_or("Yes".into()) +} -- cgit v1.2.3 From 9c7a675498ed4d83a924e963cf9a610116e6db7e Mon Sep 17 00:00:00 2001 From: Emulator000 Date: Sat, 26 Sep 2020 21:27:04 +0200 Subject: Bugfix on appearance operators and some font values --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b7cc588..7c215ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -481,7 +481,7 @@ impl Form { .map(|object| { object .as_f64() - .unwrap_or(object.as_i64().unwrap_or(0) as f64) + .unwrap_or(object.as_i64().unwrap_or(0) as f64) as f32 }) .collect::>(); @@ -500,7 +500,7 @@ impl Form { // Ignored operators let ignored_operators = vec![ - "bt", "tc", "tw", "tz", "g", "tr", "tf", "tj", "et", "q", "bmc", "emc", + "bt", "tc", "tw", "tz", "g", "tm", "tr", "tf", "tj", "et", "q", "bmc", "emc", ]; // Remove these ignored operators as we have to generate the text and fonts again @@ -553,8 +553,8 @@ impl Form { ]); // Calcolate the text offset - let x = 3.0; // Suppose this fixed offset as we should have known the border here - let y = 0.5 * (rect[3] - rect[1]) - 0.4 * font_size as f64; // Formula picked up from Poppler + let x = 2.0; // Suppose this fixed offset as we should have known the border here + let y = 0.5 * (rect[3] - rect[1]) - 0.4 * font_size as f32; // Formula picked up from Poppler // Set the text bounds, first are fixed at "1 0 0 1" and then the calculated x,y content.operations.append(&mut vec![Operation::new( -- cgit v1.2.3 From 96f39fea9921292d5aa67f478bd3d8e947f127be Mon Sep 17 00:00:00 2001 From: Emulator000 Date: Sat, 26 Sep 2020 21:56:20 +0200 Subject: Bugfix in textfield Y position calculation --- src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 7c215ee..e6200c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -554,7 +554,14 @@ impl Form { // Calcolate the text offset let x = 2.0; // Suppose this fixed offset as we should have known the border here - let y = 0.5 * (rect[3] - rect[1]) - 0.4 * font_size as f32; // Formula picked up from Poppler + + // Formula picked up from Poppler + let dy = rect[1] - rect[3]; + let y = if dy > 0.0 { + 0.5 * dy - 0.4 * font_size as f32 + } else { + 0.5 * font_size as f32 + }; // Set the text bounds, first are fixed at "1 0 0 1" and then the calculated x,y content.operations.append(&mut vec![Operation::new( -- cgit v1.2.3 From 7fb301df6d21b403c5e39e2d9d8685fd7fc7988f Mon Sep 17 00:00:00 2001 From: Emulator000 Date: Sat, 26 Sep 2020 23:05:46 +0200 Subject: Fixed bad font parsing in case of other formats --- Cargo.toml | 2 +- src/lib.rs | 53 ++++++++++++++++++++++++----------------------------- src/utils.rs | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 30 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c1396d8..2898adc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pdf_form" -version = "0.3.0" +version = "0.4.0" authors = ["Jake ", "Malte ", "Emulator000 "] readme = "README.md" keywords = ["pdf", "form"] diff --git a/src/lib.rs b/src/lib.rs index e6200c1..7ead2c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -515,41 +515,36 @@ impl Form { Operation::new("BT", vec![]), ]); - // The default font object (/Helv 12 Tf 0 g) - let default_font = ("Helv", 12, 0, "g"); - - // Build the font basing on the default appearance, if exists, if not, - // assume a default font (surely to be improved!) - let font = match da { - Object::String(ref bytes, _) => { - let values = from_utf8(bytes)? - .trim_start_matches('/') - .split(' ') - .collect::>(); - - if values.len() != 5 { - default_font - } else { - ( - values[0], - values[1].parse::().unwrap_or(0), - values[3].parse::().unwrap_or(0), - values[4], - ) - } - } - _ => default_font, - }; + let font = parse_font(match da { + Object::String(ref bytes, _) => Some(from_utf8(bytes)?), + _ => None, + }); // Define some helping font variables - let font_name = font.0; - let font_size = font.1; - let font_color = (font.2, font.3); + let font_name = (font.0).0; + let font_size = (font.0).1; + let font_color = font.1; // Set the font type and size and color content.operations.append(&mut vec![ Operation::new("Tf", vec![font_name.into(), font_size.into()]), - Operation::new(font_color.1, vec![font_color.0.into()]), + Operation::new( + font_color.0, + match font_color.0 { + "k" => vec![ + font_color.1.into(), + font_color.2.into(), + font_color.3.into(), + font_color.4.into(), + ], + "rg" => vec![ + font_color.1.into(), + font_color.2.into(), + font_color.3.into(), + ], + _ => vec![font_color.1.into()], + }, + ), ]); // Calcolate the text offset diff --git a/src/utils.rs b/src/utils.rs index 12db115..0aa342a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -70,3 +70,58 @@ pub fn get_on_value(field: &Dictionary) -> String { option.unwrap_or("Yes".into()) } + +pub fn parse_font(font_string: Option<&str>) -> ((&str, i32), (&str, i32, i32, i32, i32)) { + // The default font object (/Helv 12 Tf 0 g) + let default_font = ("Helv", 12); + let default_color = ("g", 0, 0, 0, 0); + + // Build the font basing on the default appearance, if exists, if not, + // assume a default font (surely to be improved!) + match font_string { + Some(font_string) => { + let font = font_string + .trim_start_matches('/') + .split("Tf") + .collect::>(); + + if font.len() < 2 { + (default_font, default_color) + } else { + let font_family = font[0].trim().split(' ').collect::>(); + let font_color = font[1].trim().split(' ').collect::>(); + + let font = if font_family.len() >= 2 { + (font_family[0], font_family[1].parse::().unwrap_or(0)) + } else { + default_font + }; + + let color = if font_color.len() == 2 { + ("g", font_color[0].parse::().unwrap_or(0), 0, 0, 0) + } else if font_color.len() == 4 { + ( + "rg", + font_color[0].parse::().unwrap_or(0), + font_color[1].parse::().unwrap_or(0), + font_color[2].parse::().unwrap_or(0), + 0, + ) + } else if font_color.len() == 5 { + ( + "k", + font_color[0].parse::().unwrap_or(0), + font_color[1].parse::().unwrap_or(0), + font_color[2].parse::().unwrap_or(0), + font_color[3].parse::().unwrap_or(0), + ) + } else { + default_color + }; + + (font, color) + } + } + _ => (default_font, default_color), + } +} -- cgit v1.2.3 From 6a1c7e10cbe5cddaeae59a2d70e9d7256d2a5267 Mon Sep 17 00:00:00 2001 From: Emulator000 Date: Sun, 27 Sep 2020 02:07:37 +0200 Subject: Removed unuseful commented code and ignored Cargo.lock --- .gitignore | 1 + Cargo.lock | 437 ------------------------------------------------------------- src/lib.rs | 4 - 3 files changed, 1 insertion(+), 441 deletions(-) delete mode 100644 Cargo.lock diff --git a/.gitignore b/.gitignore index a62ab56..02f6bad 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /*.data /*.gz /target/ +Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index d725e0d..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,437 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "adler" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "case" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "chrono" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-integer 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crc32fast" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-channel" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-deque" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "derive-error" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "case 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "dtoa" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "encoding" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding-index-simpchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "encoding-index-japanese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "encoding-index-korean" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "encoding-index-simpchinese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "encoding-index-singlebyte" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "encoding-index-tradchinese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "encoding_index_tests" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "flate2" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "hermit-abi" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "itoa" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.77" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "linked-hash-map" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lopdf" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "chrono 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", - "dtoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pom 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lzw" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "miniz_oxide" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "adler 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "num-integer" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "num-traits" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "hermit-abi 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pdf_form" -version = "0.3.0" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "derive-error 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lopdf 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pom" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "quote" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rayon" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon-core 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rayon-core" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-channel 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "syn" -version = "0.11.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "synom" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "time" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)", - "wasi 0.10.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-xid" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum adler 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" -"checksum autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum case 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e88b166b48e29667f5443df64df3c61dc07dc2b1a0b0d231800e07f09a33ecc1" -"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum chrono 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)" = "942f72db697d8767c22d46a598e01f2d3b475501ea43d0db4f16d90259182d0b" -"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -"checksum crossbeam-channel 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" -"checksum crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" -"checksum crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -"checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -"checksum derive-error 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ec098440b29ea3b1ece3e641bac424c19cf996779b623c9e0f2171495425c2c8" -"checksum dtoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" -"checksum either 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" -"checksum encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" -"checksum encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91" -"checksum encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81" -"checksum encoding-index-simpchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7" -"checksum encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" -"checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" -"checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" -"checksum flate2 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94" -"checksum hermit-abi 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c30f6d0bc6b00693347368a67d41b58f2fb851215ff1da49e90fe2c5c667151" -"checksum itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" -"checksum linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7860ec297f7008ff7a1e3382d7f7e1dcd69efc94751a2284bafc3d013c2aa939" -"checksum log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -"checksum lopdf 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3170bf7b90ea1fc3c4eaa1bed4882dddcfd58b79baa60fd1e10829a482f464f9" -"checksum lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084" -"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" -"checksum memoffset 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -"checksum miniz_oxide 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c60c0dfe32c10b43a144bad8fc83538c52f58302c92300ea7ec7bf7b38d5a7b9" -"checksum num-integer 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" -"checksum num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" -"checksum num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -"checksum pom 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e2192780e9f8e282049ff9bffcaa28171e1cb0844f49ed5374e518ae6024ec" -"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -"checksum rayon 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd016f0c045ad38b5251be2c9c0ab806917f82da4d36b2a327e5166adad9270" -"checksum rayon-core 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e8c4fec834fb6e6d2dd5eece3c7b432a52f0ba887cf40e595190c4107edc08bf" -"checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" -"checksum time 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" -"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" -"checksum wasi 0.10.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" -"checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/src/lib.rs b/src/lib.rs index 7ead2c4..7dc0895 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -156,10 +156,6 @@ impl Form { .ok_or(LoadError::NotAReference)? .as_dict_mut()?; - // Sets the NeedAppearances option to true into "AcroForm" in order - // to render fields correctly - // acroform.set("NeedAppearances", Object::Boolean(true)); - let fields_list = acroform.get(b"Fields")?.as_array()?; queue.append(&mut VecDeque::from(fields_list.clone())); -- cgit v1.2.3