diff --git a/ROADMAP.md b/ROADMAP.md index 5bfe1fc817..cc2416aa8a 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,5 +1,7 @@ # PdfCraft roadmap +> **Last reviewed:** 2026-11-03 | **Last updated:** 2026-11-03 | **Change:** minor (M6: copy text fields and check boxes into an independent grid; other field types remain; estimates unchanged) + > **Last reviewed:** 2026-11-03 | **Last updated:** 2026-11-03 | **Change:** patch (M5 #5850 review: indirect typewriter intent and composer edits preserve outer whitespace; movement regression commits by outside click; estimates unchanged) > **Last reviewed:** 2026-11-03 | **Last updated:** 2026-11-03 | **Change:** patch (M5 #5850: Enter adds Fill & Sign line breaks; outside clicks commit, Escape cancels, and saved multiline appearances retain their text and height; estimates unchanged) @@ -223,6 +225,8 @@ Ranked; detail and the full milestone table in [docs/roadmap.md](docs/roadmap.md ## Progress log +- **2026-11-03 (M6, form field copies):** Prepare a form can copy a text field or check box into a configurable grid of independently named fields. The copies keep their initial value and appearance, can be moved in the preview, and are added as one undoable edit; the existing table automation tool accepts a source field. Radio groups, signatures, choice fields, buttons and check boxes with per-widget export values remain unsupported. Estimates unchanged. + - **2026-11-03 (M5, #5850 review):** Resolve indirect IT when recognizing typewriter contents and Fill & Sign marks. Comment listing and property lookup retain their existing direct-Subtype behavior. A real double-click Edit composer preserves the typewriter’s text as written; ordinary comment edits keep trimming. Regressions cover direct Subtype with indirect intent, save/reopen, raw posted contents and same-index comments on different pages. The existing live-movement test now commits its setup with an outside click rather than Enter. Estimates unchanged. - **2026-11-03 (M5, #5850):** Fill & Sign Enter inserts a line break in a growing editor; clicking outside commits and Escape cancels. Nonempty text keeps leading, internal and trailing line breaks. The headless fill_sign_add path sizes its typewriter box for the same wrapped lines so saved appearances show every row. Production-order keyboard and engine save/reopen/render regressions exercise the UI and headless callers. Estimates unchanged. diff --git a/crates/automation/README.md b/crates/automation/README.md index 8ffa2d0b3e..c36e86246c 100644 --- a/crates/automation/README.md +++ b/crates/automation/README.md @@ -75,6 +75,13 @@ semantics; they never silently act on partial text. ## Shared field properties +`form_add_field_table` accepts `source_field` and the optional 1-based `source_widget` to create +independent copies of an existing text field or check box instead of blank text fields. Each copy +starts with the source's value and properties but has its own name and can be filled independently. +Radio groups, signatures, choice fields, buttons and check boxes with per-widget export values are +not supported by this option yet. The grid is one undoable edit and any invalid cell or name +refuses the entire operation. + For an individual push button, `form_set_props` also edits its visible normal label: ```json diff --git a/crates/automation/src/forms.rs b/crates/automation/src/forms.rs index adf0bd0884..2db17fc498 100644 --- a/crates/automation/src/forms.rs +++ b/crates/automation/src/forms.rs @@ -448,12 +448,33 @@ impl Automation { table.column_gap = a.opt_num("column_gap")?.unwrap_or(0.0); table.first_row = a.opt_int("first_row")?.map_or(1, |n| usize::try_from(n).unwrap_or(usize::MAX)); let info = doc.info.pages.get(page).ok_or_else(|| bad(format!("page {} does not exist", page + 1)))?; - let edit = field_table::edit(&table, page, info, &doc.form).map_err(|e| bad(e.to_string()))?; + let edit = if let Some(source) = a.opt_str("source_field")? { + let widget = a.opt_int("source_widget")?.unwrap_or(1); + let widget = usize::try_from(widget).ok().and_then(|n| n.checked_sub(1)).ok_or_else(|| bad("source_widget must be at least 1"))?; + let field = doc.form.iter().find(|f| f.name == source).ok_or_else(|| bad(format!("field {source:?} does not exist")))?; + if !matches!(field.kind, pdfcraft_engine::FormFieldKind::Text | pdfcraft_engine::FormFieldKind::CheckBox) { + return Err(bad("only text fields and check boxes can be copied into a grid")); + } + if field.widgets.get(widget).is_none() { + return Err(bad("source_widget does not exist")); + } + field_table::copy_edit(&table, page, info, &doc.form, source, widget).map_err(|e| bad(e.to_string()))? + } else { + if a.get("source_widget").is_some() { + return Err(bad("source_widget requires source_field")); + } + field_table::edit(&table, page, info, &doc.form).map_err(|e| bad(e.to_string()))? + }; // The names the batch adds, in the order it adds them. let fields: Vec = match &edit { - Edit::Batch { edits, .. } => { - edits.iter().filter_map(|e| if let Edit::AddField { name, .. } = e { name.clone() } else { None }).collect() - } + Edit::Batch { edits, .. } => edits + .iter() + .filter_map(|e| match e { + Edit::AddField { name, .. } => name.clone(), + Edit::CopyField { name, .. } => Some(name.clone()), + _ => None, + }) + .collect(), _ => Vec::new(), }; (edit, fields) diff --git a/crates/automation/src/tools.rs b/crates/automation/src/tools.rs index 4672e49886..514e12eb13 100644 --- a/crates/automation/src/tools.rs +++ b/crates/automation/src/tools.rs @@ -436,7 +436,7 @@ pub fn tools() -> Vec { t( "form_add_field_table", "Prepare form: add a table of text fields", - "Divide rect into rows and columns of text fields, one per cell, as one undo step. rect in points from the top-left of the displayed page [x0, y0, x1, y1]; rows 1-100 from the top; columns 1-50, or as many as names or widths list. Each column names its cells from its pattern in names: an N on its own after _ - / or : (price_N), # or {row} is the row number, {col} the column number, {seq} counts every cell along the rows, starting at first_row; with none of them the row number goes at the end. Rows count from first_row (default 1). Without names the columns are Table1_N, Table1_c2_N, … using the first free TableK. widths are relative (default equal); row_gap and column_gap are points between cells (default 0). Nothing is added if a cell would be under 4 points or a name would contain a period, repeat, or already exist; the error says which. Returns the fields' names. Undoable.", + "Divide rect into rows and columns of fields, one per cell, as one undo step. By default these are new text fields; source_field copies an existing text field or check box with its properties and initial value into independent fields. rect in points from the top-left of the displayed page [x0, y0, x1, y1]; rows 1-100 from the top; columns 1-50, or as many as names or widths list. Each column names its cells from its pattern in names: an N on its own after _ - / or : (price_N), # or {row} is the row number, {col} the column number, {seq} counts every cell along the rows, starting at first_row; with none of them the row number goes at the end. Rows count from first_row (default 1). Without names the columns are Table1_N, Table1_c2_N, … using the first free TableK. widths are relative (default equal); row_gap and column_gap are points between cells (default 0). Nothing is added if a cell would be under 4 points or a name would contain a period, repeat, or already exist; the error says which. Returns the fields' names. Undoable.", ) .cmd("form.add.text_table") .with(schema( @@ -451,6 +451,8 @@ pub fn tools() -> Vec { "row_gap": { "type": "number", "minimum": 0 }, "column_gap": { "type": "number", "minimum": 0 }, "first_row": { "type": "integer", "minimum": 0, "maximum": 99999 }, + "source_field": { "type": "string", "description": "Copy this existing text field or check box into each cell instead of creating blank text fields." }, + "source_widget": { "type": "integer", "minimum": 1, "description": "1-based widget of source_field (default 1)." }, }), &["doc", "page", "rect", "rows"], )), diff --git a/crates/automation/tests/it/automation.rs b/crates/automation/tests/it/automation.rs index 13f9af4371..fc96fa3c65 100644 --- a/crates/automation/tests/it/automation.rs +++ b/crates/automation/tests/it/automation.rs @@ -4537,6 +4537,30 @@ fn adding_a_field_table_through_tools() { assert_eq!(count(&mut a), 8, "one undo takes back the whole last table"); } +#[test] +fn copying_a_field_into_a_grid_through_tools() { + let dir = workdir("copy-field-grid"); + let mut a = auto(&dir); + let doc = ok(&mut a, "doc_open", json!({"path": "a.pdf"}))["doc"].as_u64().unwrap(); + ok(&mut a, "form_add_field", json!({"doc": doc, "page": 1, "type": "text", "name": "source", "rect": [20, 20, 180, 50], "multiline": true})); + ok(&mut a, "form_fill", json!({"doc": doc, "values": {"source": "initial"}})); + let args = json!({"doc": doc, "page": 1, "rect": [20, 70, 180, 150], "rows": 2, "names": ["copy_N"], "source_field": "source"}); + assert_eq!(ok(&mut a, "form_add_field_table", args.clone())["fields"], json!(["copy_1", "copy_2"])); + ok(&mut a, "form_fill", json!({"doc": doc, "values": {"copy_1": "changed"}})); + let result = ok(&mut a, "form_fields", json!({"doc": doc})); + let fields = result["fields"].as_array().unwrap(); + let get = |name: &str| fields.iter().find(|f| f["name"] == name).unwrap(); + assert_eq!(get("source")["value"], "initial"); + assert_eq!(get("copy_1")["value"], "changed"); + assert_eq!(get("copy_2")["value"], "initial"); + assert_eq!(get("copy_1")["multiline"], true); + assert_eq!(get("copy_2")["multiline"], true); + ok(&mut a, "edit_undo", json!({"doc": doc})); // undo the fill + ok(&mut a, "edit_undo", json!({"doc": doc})); // undo the complete grid + let result = ok(&mut a, "form_fields", json!({"doc": doc})); + assert_eq!(result["fields"].as_array().unwrap().len(), 1); +} + #[test] fn redact_mark_respects_single_page_and_rejects_conflicting_selectors() { let dir = workdir("redact-single-page"); diff --git a/crates/engine/src/edit.rs b/crates/engine/src/edit.rs index 8f43689aa9..aa134f552f 100644 --- a/crates/engine/src/edit.rs +++ b/crates/engine/src/edit.rs @@ -289,6 +289,14 @@ pub enum Edit { name: String, pages: Vec, }, + /// Copy one widget into a separately named field on a page. + CopyField { + source: String, + widget: usize, + page: usize, + rect: [f64; 4], + name: String, + }, DeleteField { name: String, }, diff --git a/crates/engine/src/edit/labels.rs b/crates/engine/src/edit/labels.rs index 5343804ef3..575ae1360c 100644 --- a/crates/engine/src/edit/labels.rs +++ b/crates/engine/src/edit/labels.rs @@ -158,8 +158,16 @@ pub const EDIT_LABELS: &[&str] = &[ /// The names of the batches built below L7, which an interface shows in the same places as /// [`EDIT_LABELS`] and so translates the same way. A batch built in the interface itself arrives /// already worded in the interface's language. -pub const BATCH_LABELS: &[&str] = - &["Set document title", "Mark differences", "Detect form fields", "Run JavaScript", "Recognize text", field_table::LABEL, "Style"]; +pub const BATCH_LABELS: &[&str] = &[ + "Set document title", + "Mark differences", + "Detect form fields", + "Run JavaScript", + "Recognize text", + field_table::LABEL, + field_table::COPY_LABEL, + "Style", +]; impl Edit { /// Label for the Edit menu and history ("Undo Rotate pages"). @@ -235,6 +243,7 @@ impl Edit { Edit::SetFieldProps { .. } => Label::of("Change field properties"), Edit::DeleteField { .. } | Edit::DeleteWidget { .. } => Label::of("Delete field"), Edit::DuplicateField { .. } => Label::of("Duplicate field"), + Edit::CopyField { .. } => Label::of("Duplicate field"), Edit::SetTabOrder { .. } | Edit::MoveInTabOrder { .. } => Label::of("Set tab order"), Edit::SetCalculationOrder { .. } => Label::of("Set calculation order"), Edit::SetInitialView(_) => Label::of("Change initial view"), diff --git a/crates/engine/src/edit/run.rs b/crates/engine/src/edit/run.rs index 5ed70aed7a..f4460c2a2c 100644 --- a/crates/engine/src/edit/run.rs +++ b/crates/engine/src/edit/run.rs @@ -122,6 +122,7 @@ pub(crate) fn check_permission(edit: &Edit, p: &pdfcraft_cos::Permissions) -> Re | Edit::DeleteField { .. } | Edit::DeleteWidget { .. } | Edit::DuplicateField { .. } + | Edit::CopyField { .. } | Edit::SetTabOrder { .. } | Edit::MoveInTabOrder { .. } | Edit::SetCalculationOrder { .. } @@ -642,6 +643,9 @@ pub(crate) fn run_edit(doc: &mut pdfcraft_cos::Document, edit: &Edit, cx: &mut E return Err(EditError::Form(pdfcraft_forms::FormError::Invalid(format!("{name} is already on those pages")))); } } + Edit::CopyField { source, widget, page, rect, name } => { + pdfcraft_forms::copy_field(doc, source, *widget, *page, *rect, name)?; + } Edit::DeleteField { name } => pdfcraft_forms::delete_field(doc, name)?, Edit::DeleteWidget { name, widget } => pdfcraft_forms::delete_widget(doc, name, *widget)?, Edit::SetTabOrder { pages, order } => pdfcraft_forms::set_tab_order(doc, pages, *order)?, diff --git a/crates/engine/src/field_table.rs b/crates/engine/src/field_table.rs index f3fd96551e..fa8262da89 100644 --- a/crates/engine/src/field_table.rs +++ b/crates/engine/src/field_table.rs @@ -12,6 +12,9 @@ use crate::{Edit, FormField, NewField}; /// The edit's name in the history ("Undo Add text field table"), one of [`crate::BATCH_LABELS`]. pub const LABEL: &str = "Add text field table"; +/// The history entry for a grid copied from an existing field. +pub const COPY_LABEL: &str = "Create multiple field copies"; + /// The edit adding `table`'s cells to `page` (0-based, shown as `info`) of a document whose /// fields are `form`. Refused, with nothing added, when a cell would be too small on the page or /// its name can't be used. @@ -40,6 +43,24 @@ pub fn edit(table: &FieldTable, page: usize, info: &PageInfo, form: &[FormField] Ok(Edit::Batch { label: LABEL.to_owned(), edits }) } +/// Lay out a grid of independent copies of one existing field widget. +pub fn copy_edit(table: &FieldTable, page: usize, info: &PageInfo, form: &[FormField], source: &str, widget: usize) -> Result { + let batch = edit(table, page, info, form)?; + Ok(match batch { + Edit::Batch { edits, .. } => Edit::Batch { + label: COPY_LABEL.to_owned(), + edits: edits + .into_iter() + .map(|edit| match edit { + Edit::AddField { page, rect, name: Some(name), .. } => Edit::CopyField { source: source.to_owned(), widget, page, rect, name }, + other => other, + }) + .collect(), + }, + other => other, + }) +} + #[cfg(test)] mod tests { use super::*; @@ -81,6 +102,29 @@ mod tests { assert!(s.get(id).unwrap().form.is_empty(), "one undo takes the whole table back"); } + #[test] + fn a_grid_of_field_copies_is_one_undoable_edit() { + let mut s = Session::new(); + let bytes = s.create_blank(300.0, 400.0, 1).unwrap(); + let id = s.open("copies.pdf", None, bytes, None).unwrap(); + s.apply( + id, + Edit::AddField { page: 0, rect: [30.0, 330.0, 130.0, 350.0], kind: NewField::Text { multiline: true }, name: Some("source".into()) }, + ) + .unwrap(); + let table = grid([30.0, 100.0, 230.0, 180.0], 2, &["a_N", "b_N"]); + let doc = s.get(id).unwrap(); + let edit = copy_edit(&table, 0, &doc.info.pages[0], &doc.form, "source", 0).unwrap(); + s.apply(id, edit).unwrap(); + let form = &s.get(id).unwrap().form; + assert_eq!(form.len(), 5); + for name in ["a_1", "b_1", "a_2", "b_2"] { + assert!(form.iter().find(|f| f.name == name).unwrap().has(pdfcraft_forms::flags::MULTILINE)); + } + assert_eq!(s.undo(id).unwrap().to_string(), COPY_LABEL); + assert_eq!(s.get(id).unwrap().form.len(), 1); + } + #[test] fn rows_run_down_a_turned_page_as_it_is_shown() { let mut s = Session::new(); diff --git a/crates/forms/src/author.rs b/crates/forms/src/author.rs index de597187d4..cc8195cd1a 100644 --- a/crates/forms/src/author.rs +++ b/crates/forms/src/author.rs @@ -19,7 +19,7 @@ mod tree; pub(crate) use tree::ancestor_sets; pub use edit::set_props; -pub use lifecycle::{add_field, delete_field, delete_field_object, delete_widget, duplicate_field}; +pub use lifecycle::{add_field, copy_field, delete_field, delete_field_object, delete_widget, duplicate_field}; pub(crate) use look::button_appearance; pub use look::{BorderStyle, CheckStyle, FieldFont, Look, LookPatch, check_style, look, redraw_field, set_button_icon}; pub(crate) use tree::{ensure_form, form_fonts_as_objects}; diff --git a/crates/forms/src/author/lifecycle.rs b/crates/forms/src/author/lifecycle.rs index f719292a80..3b173862ff 100644 --- a/crates/forms/src/author/lifecycle.rs +++ b/crates/forms/src/author/lifecycle.rs @@ -1,5 +1,5 @@ use super::look::redraw_field; -use super::tree::{add_to_page, attach, clash, detach, ensure_form, free_name, name_parts, top_names}; +use super::tree::{add_to_page, attach, clash, detach, ensure_form, free_name, inherited, name_parts, top_names}; use super::{ Dict, Document, Field, FieldKind, FormError, MIN_FIELD_SIDE, NewField, ObjRef, Object, PdfString, Widget, appearance, fields, flags, invalid, page_refs, rgb, @@ -325,6 +325,89 @@ pub(super) fn split_triggers(aa: &Dict) -> (Option, Option) { (some(widget), some(field)) } +/// Copy one widget into a new, independently named field on a page. +/// +/// The field's current value and properties are copied, but the new field has its own value. +/// Radio groups and signature fields require special handling and are not supported here. +pub fn copy_field(doc: &mut Document, name: &str, widget: usize, page: usize, rect: [f64; 4], new_name: &str) -> Result<(), FormError> { + let all = fields(doc); + let f = all.iter().find(|f| f.name == name).ok_or_else(|| FormError::NoSuchField(name.into()))?; + if !matches!(f.kind, FieldKind::Text | FieldKind::CheckBox) { + return invalid("only text fields and check boxes can be copied into a grid"); + } + if f.kind == FieldKind::CheckBox && f.widgets.len() > 1 && !f.options.is_empty() { + return invalid("a check box with per-widget export values cannot yet be copied into a grid"); + } + let w = f.widgets.get(widget).ok_or_else(|| FormError::Invalid(format!("{name} has no widget {}", widget.saturating_add(1))))?; + let page_ref = *page_refs(doc).get(page).ok_or_else(|| FormError::Invalid(format!("page {} does not exist", page.saturating_add(1))))?; + let width = rect[2] - rect[0]; + let height = rect[3] - rect[1]; + if !rect.iter().all(|v| v.is_finite()) || !width.is_finite() || !height.is_finite() || width < MIN_FIELD_SIDE || height < MIN_FIELD_SIDE { + return invalid("the field is too small"); + } + let parts = name_parts(new_name)?; + if let Some(why) = all.iter().find_map(|other| clash(new_name, &other.name)) { + return invalid(why); + } + let mut field = doc.get(f.obj).as_dict().cloned().ok_or_else(|| FormError::Invalid("field is not a dictionary".into()))?; + let widget_dict = doc.get(w.obj).as_dict().cloned().ok_or_else(|| FormError::Invalid("widget is not a dictionary".into()))?; + for (k, v) in inherited(doc, f.obj).iter() { + field.set(k.to_vec(), v.clone()); + } + if w.obj != f.obj { + // Preserve widget entries that aren't in the field dictionary, including unfamiliar + // annotation keys, while the field's own attributes keep their precedence. + for (key, value) in widget_dict.iter() { + if !field.contains(key) && !matches!(key.as_slice(), b"Parent" | b"Kids" | b"T" | b"AA" | b"NM" | b"StructParent") { + field.set(key.clone(), value.clone()); + } + } + for key in WIDGET_KEYS { + if let Some(value) = widget_dict.get(key) { + field.set(key.to_vec(), value.clone()); + } + } + if let Some(da) = widget_dict.get(b"DA") { + field.set(b"DA".to_vec(), da.clone()); + } + // Keep both field and widget event dictionaries when they were separate. + let mut aa = field.get(b"AA").and_then(|a| doc.resolve(a).as_dict().cloned()).unwrap_or_default(); + if let Some(widget_aa) = widget_dict.get(b"AA").and_then(|a| doc.resolve(a).as_dict().cloned()) { + for (k, v) in widget_aa.iter() { + aa.set(k.to_vec(), v.clone()); + } + } + if aa.iter().next().is_some() { + field.set(b"AA".to_vec(), Object::Dict(aa)); + } + } + for key in [&b"Kids"[..], b"Parent", b"T", b"NM", b"StructParent"] { + field.remove(key); + } + // The appearance editor updates indirect /MK and /BS dictionaries in place. Make these + // per-widget dictionaries direct so editing a copy cannot restyle the source or its siblings. + for key in [&b"MK"[..], b"BS"] { + if let Some(value) = field.get(key).filter(|v| Object::as_ref(v).is_some()) + && let Some(dict) = doc.resolve(value).as_dict().cloned() + { + field.set(key.to_vec(), Object::Dict(dict)); + } + } + field.set(b"P".to_vec(), Object::Ref(page_ref)); + field.set(b"Rect".to_vec(), Object::Array(rect.iter().map(|v| Object::Real(*v)).collect())); + // Keep a custom appearance rather than replacing it with a generated approximation. + // A viewer scales its appearance stream to the new widget rectangle. + let has_appearance = field.get(b"AP").is_some_and(|o| matches!(&*doc.resolve(o), Object::Dict(d) if d.contains(b"N"))); + let af = ensure_form(doc)?; + let copied = doc.add(Object::Dict(field)); + attach(doc, af, copied, &parts)?; + add_to_page(doc, page_ref, copied)?; + if !has_appearance { + redraw_field(doc, new_name)?; + } + Ok(()) +} + /// Duplicate a field onto other pages (Acrobat: right-click a field ▸ Duplicate): each page /// gets a widget at the same place, belonging to the same field, so they share one value. /// A field that is its own widget is first split into a field and a widget kid. Returns how diff --git a/crates/forms/src/lib.rs b/crates/forms/src/lib.rs index 775306d865..a9a8ed2fad 100644 --- a/crates/forms/src/lib.rs +++ b/crates/forms/src/lib.rs @@ -26,7 +26,7 @@ mod scripting; pub mod table; pub use actions::{FieldAction, Trigger, field_action_chains, field_actions, set_field_actions}; pub use author::{ - BorderStyle, CheckStyle, FieldFont, FieldProps, Look, LookPatch, MIN_FIELD_SIDE, NewField, add_field, check_style, delete_field, + BorderStyle, CheckStyle, FieldFont, FieldProps, Look, LookPatch, MIN_FIELD_SIDE, NewField, add_field, check_style, copy_field, delete_field, delete_field_object, delete_widget, duplicate_field, look, redraw_field, set_button_icon, set_props, }; pub use calc_order::{CalculatedField, CalculationIssue, CalculationOrder, calculation_order, set_calculation_order}; diff --git a/crates/forms/src/tests.rs b/crates/forms/src/tests.rs index cca4cb4881..38691a34dd 100644 --- a/crates/forms/src/tests.rs +++ b/crates/forms/src/tests.rs @@ -39,6 +39,114 @@ fn fixture() -> Document { document(&objs) } +#[test] +fn grid_copy_preserves_properties_and_has_an_independent_value() { + let mut doc = fixture(); + let source = field(&fields(&doc), "notes").clone(); + copy_field(&mut doc, "notes", 0, 0, [50.0, 400.0, 250.0, 480.0], "notes_1").unwrap(); + let copied = field(&fields(&doc), "notes_1").clone(); + assert_eq!(copied.kind, source.kind); + assert_eq!(copied.flags, source.flags); + assert_eq!(copied.da, source.da); + assert_eq!(copied.widgets[0].rect, [50.0, 400.0, 250.0, 480.0]); + set_value(&mut doc, "notes_1", &FieldValue::Text("new value".into())).unwrap(); + let reopened = reopen(&doc); + let all = fields(&reopened); + assert_eq!(field(&all, "notes_1").value, ["new value"]); + assert_ne!(field(&all, "notes").value, ["new value"]); +} + +#[test] +fn grid_copy_checkbox_preserves_appearance_and_rejects_taken_names() { + let mut doc = fixture(); + copy_field(&mut doc, "agree", 0, 0, [350.0, 400.0, 370.0, 420.0], "agree_copy").unwrap(); + let all = fields(&doc); + assert_eq!(field(&all, "agree_copy").kind, FieldKind::CheckBox); + assert_eq!(field(&all, "agree_copy").widgets[0].on_state, field(&all, "agree").widgets[0].on_state); + let copied_ap = doc.get(field(&all, "agree_copy").widgets[0].obj).as_dict().unwrap().get(b"AP").cloned(); + let source_ap = doc.get(field(&all, "agree").widgets[0].obj).as_dict().unwrap().get(b"AP").cloned(); + assert_eq!(copied_ap, source_ap, "custom checkbox appearance is preserved"); + set_value(&mut doc, "agree_copy", &FieldValue::Check(true)).unwrap(); + let reopened = reopen(&doc); + let all = fields(&reopened); + assert_ne!(field(&all, "agree_copy").value, field(&all, "agree").value); + let before = all.len(); + assert!(copy_field(&mut doc, "agree", 0, 0, [0.0, 0.0, 20.0, 20.0], "agree_copy").is_err()); + assert_eq!(fields(&doc).len(), before); + assert!(copy_field(&mut doc, "size", 0, 0, [0.0, 0.0, 20.0, 20.0], "radio_copy").is_err()); +} + +#[test] +fn grid_copy_does_not_share_indirect_appearance_dictionaries() { + let mut doc = fixture(); + let source = field(&fields(&doc), "name").obj; + let source_dict = doc.get(source).as_dict().unwrap().clone(); + let mk = doc.add(source_dict.get(b"MK").unwrap().clone()); + let mut bs = pdfcraft_cos::Dict::new(); + bs.set(b"W".to_vec(), Object::Real(1.0)); + let bs = doc.add(Object::Dict(bs)); + doc.update_dict(source, |d| { + d.set(b"MK".to_vec(), Object::Ref(mk)); + d.set(b"BS".to_vec(), Object::Ref(bs)); + }) + .unwrap(); + copy_field(&mut doc, "name", 0, 0, [50.0, 400.0, 250.0, 420.0], "name_copy").unwrap(); + let before = look(&doc, field(&fields(&doc), "name")); + let props = FieldProps { + appearance: Some(LookPatch { fill: Some(Some([0.0, 0.0, 1.0])), width: Some(3.0), ..Default::default() }), + ..Default::default() + }; + set_props(&mut doc, "name_copy", &props).unwrap(); + let all = fields(&doc); + assert_eq!(look(&doc, field(&all, "name")), before); + assert_ne!(look(&doc, field(&all, "name_copy")), before); +} + +#[test] +fn grid_copy_preserves_inherited_properties_and_rejects_invalid_geometry() { + let mut doc = fixture(); + let source = field(&fields(&doc), "address.city").obj; + let parent = doc.get(source).as_dict().unwrap().reference(b"Parent").unwrap(); + doc.update_dict(source, |d| { + d.remove(b"FT"); + }) + .unwrap(); + doc.update_dict(parent, |d| { + d.set(b"FT".to_vec(), Object::name("Tx")); + d.set(b"Ff".to_vec(), Object::Int(i64::from(flags::MULTILINE))); + }) + .unwrap(); + copy_field(&mut doc, "address.city", 0, 0, [50.0, 400.0, 250.0, 420.0], "city_copy").unwrap(); + let all = fields(&doc); + assert!(field(&all, "city_copy").has(flags::MULTILINE)); + let before = all.len(); + for rect in [[f64::NAN, 0.0, 20.0, 20.0], [0.0, 0.0, f64::INFINITY, 20.0], [-f64::MAX, 0.0, f64::MAX, 20.0], [0.0; 4]] { + assert!(copy_field(&mut doc, "address.city", 0, 0, rect, "invalid_copy").is_err()); + assert_eq!(fields(&doc).len(), before); + } +} + +#[test] +fn grid_copy_keeps_widget_overrides_when_field_and_widget_are_separate() { + let objs: Vec = vec![ + "<< /Type /Catalog /Pages 2 0 R /AcroForm 4 0 R >>".into(), + "<< /Type /Pages /Kids [3 0 R] /Count 1 /MediaBox [0 0 300 400] >>".into(), + "<< /Type /Page /Parent 2 0 R /Annots [6 0 R] >>".into(), + "<< /Fields [5 0 R] >>".into(), + "<< /FT /Tx /T (source) /DA (/Helv 12 Tf 0 g) /Kids [6 0 R] >>".into(), + "<< /Type /Annot /Subtype /Widget /Parent 5 0 R /P 3 0 R /Rect [20 300 120 320] /DA (/Helv 8 Tf 1 0 0 rg) /Foo (kept) /NM (unique) >>".into(), + ]; + let mut doc = document(&objs); + copy_field(&mut doc, "source", 0, 0, [20.0, 250.0, 120.0, 270.0], "copy").unwrap(); + let all = fields(&doc); + let copy = field(&all, "copy"); + let object = doc.get(copy.obj); + let dict = object.as_dict().unwrap(); + assert!(dict.contains(b"Foo")); + assert!(!dict.contains(b"NM"), "an annotation name must not be duplicated"); + assert_eq!(copy.da, "/Helv 8 Tf 1 0 0 rg"); +} + /// A PDF of the given objects (numbered from 1). fn document(objs: &[String]) -> Document { let mut out = b"%PDF-1.7\n".to_vec(); diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 49d2c44b03..9b269958b8 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -2642,6 +2642,14 @@ fn draw_pages( field_menu = Some(FieldMenu::Duplicate(name.clone())); ui.close(); } + let can_copy = form + .iter() + .find(|f| f.name == name) + .is_some_and(|f| matches!(f.kind, pdfcraft_engine::FormFieldKind::Text | pdfcraft_engine::FormFieldKind::CheckBox)); + if ui.add_enabled(can_modify && can_copy && view.prepare.also.is_empty(), egui::Button::new(tl!("Create Multiple Copies…"))).clicked() { + field_menu = Some(FieldMenu::Copies(name.clone(), wi)); + ui.close(); + } ui.separator(); let delete = if view.prepare.also.is_empty() { "Delete" } else { "Delete selected fields" }; if ui.add_enabled(can_modify, egui::Button::new(tl!(delete))).clicked() { @@ -3929,10 +3937,35 @@ fn apply_frame_requests(app: &mut PdfCraftApp, index: usize, ui: &mut egui::Ui, if let Some((name, w)) = field_props { app.open_field_props(&name, w); } - if let Some(FieldMenu::Duplicate(name)) = field_menu { - let pages = app.session.get(app.views[index].id).map_or(1, |d| d.info.pages.len()); - app.duplicate_draft = Some(crate::DuplicateDraft { name, all: true, from: 1, to: pages }); - app.dialog = Some(crate::Dialog::DuplicateField); + match field_menu { + Some(FieldMenu::Duplicate(name)) => { + let pages = app.session.get(app.views[index].id).map_or(1, |d| d.info.pages.len()); + app.duplicate_draft = Some(crate::DuplicateDraft { name, all: true, from: 1, to: pages }); + app.dialog = Some(crate::Dialog::DuplicateField); + } + Some(FieldMenu::Copies(name, widget)) => { + let draft = (|| { + let doc = app.session.get(app.views[index].id)?; + let selected = form.iter().find(|f| f.name == name)?.widgets.get(widget)?; + let page = selected.page?; + let info = doc.info.pages.get(page)?; + let (rect, rows, columns) = crate::field_table_ui::copy_grid(info, selected.rect)?; + let mut draft = crate::field_table_ui::FieldTableDraft::new(doc.id, page, rect, &form, generation); + draft.table.rows = rows; + draft.table.set_columns(columns, "Copy"); + draft.source = Some((name, widget)); + Some(draft) + })(); + if let Some(draft) = draft { + app.field_table_draft = Some(draft); + app.dialog = Some(crate::Dialog::FieldTable); + app.left = crate::LeftPanel::Tool("form"); + app.reveal_tools(); + } else { + app.notify_tr("There is not enough space beside this field for the copies."); + } + } + _ => {} } if let Some((page, rect)) = app.views[index].links.open_new.take() { app.open_link_props(page, Some(rect), None); @@ -4118,6 +4151,7 @@ fn apply_frame_requests(app: &mut PdfCraftApp, index: usize, ui: &mut egui::Ui, enum FieldMenu { Properties, Duplicate(String), + Copies(String, usize), } #[cfg(test)] diff --git a/crates/ui-egui/src/editing.rs b/crates/ui-egui/src/editing.rs index b810e2abe5..ca3bd7754c 100644 --- a/crates/ui-egui/src/editing.rs +++ b/crates/ui-egui/src/editing.rs @@ -920,6 +920,7 @@ fn is_form_edit(edit: &Edit) -> bool { | Edit::DeleteField { .. } | Edit::DeleteWidget { .. } | Edit::DuplicateField { .. } + | Edit::CopyField { .. } | Edit::SetFieldProps { .. } | Edit::SetFieldImage { .. } | Edit::SetFieldScript { .. } diff --git a/crates/ui-egui/src/tools/field_table_ui.rs b/crates/ui-egui/src/tools/field_table_ui.rs index 6dacf67a65..22b63c3363 100644 --- a/crates/ui-egui/src/tools/field_table_ui.rs +++ b/crates/ui-egui/src/tools/field_table_ui.rs @@ -32,6 +32,8 @@ pub struct FieldTableDraft { /// The page it goes on, 0-based. pub page: usize, pub table: FieldTable, + /// The field widget to copy, or none for a new table of text fields. + pub source: Option<(String, usize)>, /// What added columns are named after: the first free "TableK" when the window opened. base: String, /// The document's edit generation when the window opened: any edit since closes it. @@ -45,7 +47,8 @@ pub struct FieldTableDraft { /// Two drafts are the same table in the same place; what is kept for the next frame isn't part of it. impl PartialEq for FieldTableDraft { fn eq(&self, other: &Self) -> bool { - (self.doc, self.page, &self.table, &self.base, self.generation) == (other.doc, other.page, &other.table, &other.base, other.generation) + (self.doc, self.page, &self.table, &self.base, self.generation, &self.source) + == (other.doc, other.page, &other.table, &other.base, other.generation, &other.source) } } @@ -70,12 +73,44 @@ enum Choice { Cancel, } +/// A two-copy starting grid beside the source, wholly within the displayed page. +pub(crate) fn copy_grid(info: &PageInfo, rect: [f64; 4]) -> Option<([f64; 4], usize, usize)> { + let a = info.user_to_view(rect[0] as f32, rect[1] as f32); + let b = info.user_to_view(rect[2] as f32, rect[3] as f32); + let (left, right) = (f64::from(a[0].min(b[0])), f64::from(a[0].max(b[0]))); + let (top, bottom) = (f64::from(a[1].min(b[1])), f64::from(a[1].max(b[1]))); + let (width, height) = (right - left, bottom - top); + let (page_width, page_height) = (f64::from(info.width), f64::from(info.height)); + if ![left, right, top, bottom, width, height, page_width, page_height].iter().all(|v| v.is_finite()) + || width < 4.0 + || height < 4.0 + || left < 0.0 + || top < 0.0 + || right > page_width + || bottom > page_height + { + return None; + } + let gap = 8.0; + if bottom + gap + height * 2.0 <= page_height { + Some(([left, bottom + gap, right, bottom + gap + height * 2.0], 2, 1)) + } else if top >= gap + height * 2.0 { + Some(([left, top - gap - height * 2.0, right, top - gap], 2, 1)) + } else if right + gap + width * 2.0 <= page_width { + Some(([right + gap, top, right + gap + width * 2.0, bottom], 1, 2)) + } else if left >= gap + width * 2.0 { + Some(([left - gap - width * 2.0, top, left - gap, bottom], 1, 2)) + } else { + None + } +} + impl FieldTableDraft { /// A table filling `rect` (view space) on `page` of a document at edit `generation`, named after /// the first base `form` leaves free. pub(crate) fn new(doc: DocId, page: usize, rect: [f64; 4], form: &[FormField], generation: u64) -> Self { let base = field_table::free_base(form.iter().map(|f| f.name.as_str())); - FieldTableDraft { doc, page, table: FieldTable::new(rect, &base), base, generation, laid: None, typing: false } + FieldTableDraft { doc, page, table: FieldTable::new(rect, &base), source: None, base, generation, laid: None, typing: false } } /// The table laid out on its page (`info`, in a form whose fields are `form`), worked out again @@ -85,8 +120,11 @@ impl FieldTableDraft { if let Some(laid) = self.laid.as_ref().filter(|l| l.table == self.table) { return Arc::clone(laid); } - let laid = - Arc::new(Laid { table: self.table.clone(), cells: self.table.cells(), edit: field_table::edit(&self.table, self.page, info, form) }); + let edit = match &self.source { + Some((source, widget)) => field_table::copy_edit(&self.table, self.page, info, form, source, *widget), + None => field_table::edit(&self.table, self.page, info, form), + }; + let laid = Arc::new(Laid { table: self.table.clone(), cells: self.table.cells(), edit }); self.laid = Some(Arc::clone(&laid)); laid } @@ -158,7 +196,8 @@ pub(crate) fn show(app: &mut PdfCraftApp, ctx: &egui::Context) { let mut open = true; let mut choice = None; let mut laid = None; - egui::Window::new(tl!("Text Field Table")) + let title = if draft.source.is_some() { tl!("Create Multiple Copies") } else { tl!("Text Field Table") }; + egui::Window::new(title) .id(egui::Id::unique("field_table_window")) .open(&mut open) .collapsible(false) @@ -203,6 +242,10 @@ fn close(app: &mut PdfCraftApp) { /// The window's controls, the names the table will have, and why it can't be added if it can't. /// Returns what was chosen and the table as it now stands, laid out and checked. fn body(ui: &mut egui::Ui, d: &mut FieldTableDraft, info: &PageInfo, form: &[FormField], t: &theme::Tokens) -> (Option, Arc) { + if d.source.is_some() { + copy_grid_controls(ui, d, info); + ui.add_space(6.0); + } let columns = d.table.columns.len(); egui::Grid::new("field_table_grid").num_columns(2).spacing([14.0, 8.0]).min_col_width(120.0).show(ui, |ui| { ui.label(tl!("Rows")); @@ -311,6 +354,36 @@ fn body(ui: &mut egui::Ui, d: &mut FieldTableDraft, info: &PageInfo, form: &[For (choice, laid) } +/// The grid area in displayed-page points. A changed position keeps the area on the page. +fn copy_grid_controls(ui: &mut egui::Ui, d: &mut FieldTableDraft, info: &PageInfo) { + let [mut left, mut top, right, bottom] = d.table.rect; + let (mut width, mut height) = (right - left, bottom - top); + let (page_width, page_height) = (f64::from(info.width), f64::from(info.height)); + if ![left, top, width, height, page_width, page_height].iter().all(|n| n.is_finite()) || page_width < 4.0 || page_height < 4.0 { + return; + } + let mut changed = false; + ui.horizontal(|ui| { + changed |= copy_grid_number(ui, "Left", &mut left, 0.0..=(page_width - width).max(0.0)); + changed |= copy_grid_number(ui, "Top", &mut top, 0.0..=(page_height - height).max(0.0)); + }); + ui.horizontal(|ui| { + changed |= copy_grid_number(ui, "Width", &mut width, 4.0..=(page_width - left).max(4.0)); + changed |= copy_grid_number(ui, "Height", &mut height, 4.0..=(page_height - top).max(4.0)); + }); + if changed { + d.table.rect = [left, top, left + width, top + height]; + } +} + +fn copy_grid_number(ui: &mut egui::Ui, label: &str, value: &mut f64, range: RangeInclusive) -> bool { + let label = ui.label(tl!(label)); + let response = ui.add(egui::DragValue::new(value).range(range).speed(0.5).suffix(" pt")); + let changed = response.changed(); + response.labelled_by(label.id); + changed +} + /// "Column 2" for the column at 0-based `index`. fn column_label(index: usize) -> String { i18n::fmt(tl!("Column {n}"), &[("n", &index.saturating_add(1).to_string())]) @@ -456,6 +529,18 @@ mod tests { use super::*; + #[test] + fn a_copy_grid_starts_on_the_page_without_covering_the_source() { + let info = PageInfo { width: 400.0, height: 300.0, label: "1".into(), crop: [0.0, 0.0, 400.0, 300.0], rotation: 0 }; + let (below, rows, columns) = copy_grid(&info, [10.0, 270.0, 110.0, 290.0]).unwrap(); + assert_eq!((rows, columns), (2, 1)); + assert!(below.iter().zip([10.0, 38.0, 110.0, 78.0]).all(|(a, b)| (a - b).abs() < 1e-3), "{below:?}"); + let (above, rows, columns) = copy_grid(&info, [10.0, 0.0, 110.0, 20.0]).unwrap(); + assert_eq!((rows, columns), (2, 1)); + assert!(above.iter().zip([10.0, 232.0, 110.0, 272.0]).all(|(a, b)| (a - b).abs() < 1e-3), "{above:?}"); + assert!(copy_grid(&info, [0.0, 0.0, 400.0, 300.0]).is_none()); + } + fn draft(columns: usize) -> FieldTableDraft { let mut d = FieldTableDraft::new(DocId(1), 0, [0.0, 0.0, 400.0, 200.0], &[], 0); d.table.set_columns(columns, &d.base); diff --git a/crates/ui-egui/tests/it/prepare.rs b/crates/ui-egui/tests/it/prepare.rs index 82e33b29de..cce9a42313 100644 --- a/crates/ui-egui/tests/it/prepare.rs +++ b/crates/ui-egui/tests/it/prepare.rs @@ -576,6 +576,45 @@ fn duplicating_a_field_onto_every_page() { assert_eq!(doc.can_undo(), Some("Duplicate field")); } +#[test] +fn copying_a_field_into_a_grid_from_its_context_menu() { + let mut h = harness(); + h.state_mut().execute("form.prepare"); + h.run_steps(3); + let before = names(&h); + let p = { + let s = h.state(); + let doc = s.session.get(s.views[0].id).unwrap(); + let f = doc.form.iter().find(|f| f.name == "city").unwrap(); + pdfcraft_ui_egui::forms_ui::field_screen_rect(&s.views[0], &doc.info, f, 0).unwrap().center() + }; + h.hover_at(p); + h.run_steps(1); + h.event(egui::Event::PointerButton { pos: p, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() }); + h.event(egui::Event::PointerButton { pos: p, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() }); + h.run_steps(3); + h.get_by_label("Create Multiple Copies…").click(); + h.run_steps(2); + h.get_by_label("Create Multiple Copies"); + assert_eq!(h.state().field_table_draft.as_ref().unwrap().source.as_ref().unwrap().0, "city"); + if let Ok(path) = std::env::var("PDFCRAFT_FIELD_COPIES_SHOT") { + let _gpu = crate::gpu(); + for _ in 0..20 { + h.run_steps(2); + if !h.state().render_pending() { + break; + } + } + h.render().unwrap().save(path).unwrap(); + } + h.get_by_label("Add fields").click(); + h.run_steps(3); + assert_eq!(names(&h).len(), before.len() + 2); + h.state_mut().execute("edit.undo"); + h.run_steps(2); + assert_eq!(names(&h), before); +} + #[test] fn aligning_distributing_and_sizing_several_fields() { use pdfcraft_ui_egui::prepare::{Arrange, arrange}; diff --git a/docs/gaps.md b/docs/gaps.md index 4f35e651d1..7ae54dc694 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,5 +1,7 @@ # Where PdfCraft falls short of Acrobat Pro +> **Last reviewed:** 2026-11-03 · **Last updated:** 2026-11-03 · **Change:** minor (gap 15: grid copies for text fields and check boxes; other field types remain; estimates unchanged) + > **Last reviewed:** 2026-10-25 · **Last updated:** 2026-10-25 · **Change:** minor (gaps 5 and 14 current state: native release Hans face via LXGW WenKai Lite; Arabic logical catalog, explicit RTL direction and mirrored stock chrome, with native/browser/IME workflows unqualified; no readiness re-estimate) > **Last reviewed:** 2026-10-15 · **Last updated:** 2026-10-15 · **Change:** minor (gap 3: #2517 a blank line stays a paragraph break; estimates unchanged) · **Target:** Adobe Acrobat Pro (Acrobat DC, continuous track 26.002.21931, macOS) @@ -332,6 +334,9 @@ update the numbers. ### 15. Forms: JavaScript object model, actions, submit, XFA depth +- **Grid copies:** an existing text field or check box can be copied into an independently named + grid. Radio groups, choice fields, buttons, signatures and check boxes with per-widget export + values remain unsupported. - **Missing:** the wider Acrobat JavaScript object model (annotations, layers, dialogs), document actions, the Actions tab triggers that run JavaScript, form submission, the debugger, barcode fields, rich-text values; XFA flattening and complete dynamic-form fidelity. @@ -412,6 +417,7 @@ update the numbers. | Date | Change | Summary | |---|---|---| +| 2026-11-03 | minor | Gap 15: copying existing text fields and check boxes into a grid is available; other field types remain. Estimates unchanged. | | 2026-10-25 | minor | Gaps 5 and 14 current state: native release builds embed LXGW WenKai Lite for Simplified Chinese, while the web build has no Hans face; Arabic catalogs stay logical with explicit RTL label direction and mirrored stock chrome, while native/browser RTL input, IME and complex workflows remain unqualified. Estimates unchanged. | | 2026-10-18 | minor | Gap 3: #2517 a partial rewrite keeps a kept source row in the paragraph and leaves the next marked region closed around its text. Estimates unchanged. | | 2026-10-15 | minor | Gap 3: #2517 a blank line at ordinary leading stays a paragraph break. Estimates unchanged. | diff --git a/docs/roadmap.md b/docs/roadmap.md index f376f7cb00..60bdca752a 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -1,5 +1,7 @@ # PdfCraft roadmap: milestones and what's next +> **Last reviewed:** 2026-11-03 | **Last updated:** 2026-11-03 | **Change:** minor (M6: grid copies of text fields and check boxes; additional field types remain; estimates unchanged) + > **Last reviewed:** 2026-11-03 | **Last updated:** 2026-11-03 | **Change:** patch (M5 #5850 review: indirect typewriter intent and composer edits preserve outer whitespace; movement regression commits by outside click; estimates unchanged) > **Last reviewed:** 2026-11-03 | **Last updated:** 2026-11-03 | **Change:** patch (M5 #5850: Enter adds Fill & Sign line breaks; outside clicks commit, Escape cancels, and saved multiline appearances retain their text and height; estimates unchanged) @@ -227,7 +229,7 @@ total matches the parity estimate. | M4 | Engine, history, save, organize | 100–180 | 95% | 8–15 | Done:
- command registry (menus, shortcuts and palette all use it);
- undo/redo; incremental, atomic and encrypted saves;
- autosave and crash recovery;
- organize, combine, extract, split and insert-from-file, with identical fonts and images stored once;
- CLI `edit/combine/extract/split`.
Done since: Combine files in its own tab (sortable, resizable columns; folders; early warnings; unlocking protected files), bookmark editing, page labels (Number pages), CLI `run`, Set Page Boxes, Crop tool, Duplicate pages, Ctrl+A / Cmd+A to select all pages in Organize, Replace pages, bookmarks from tagged headings. Missing: page transitions, recovery on the web M4: Insert-from-file preserves source bookmarks; integration tests retained with current main. | | M5 | Comments (all annotation types, XFDF) | 120–200 | 88% | 12–25 | Done: notes, highlight/underline/strikeout/squiggly, text boxes, ink, lines, arrows, rectangles, ovals, stamps (dynamic, Sign Here, Standard Business), with appearance streams; replies, status, checkmarks, locking, move/resize/restyle/delete; properties dialog; panel filter and sort; hide all; summaries (comments only); XFDF/FDF import and export (partial imports preserve existing reply and review-status links); flatten; Fill & Sign with adjustable text/date size; agent tools.
Done since: stamps placed on a rotated page read upright (#1398); polygons, connected lines, clouds, callouts, inserted text, colour and checkmark filters; image signature pointer previews, selection handles and live image movement/resizing with proportional corners and independent edge handles. Missing: custom stamps, replace-text proposals, summary layouts with the page | | M5 | Comments (all annotation types, XFDF) | 120–200 | 88% | 12–25 | Done: notes, highlight/underline/strikeout/squiggly, text boxes, ink, lines, arrows, rectangles, ovals, stamps (dynamic, Sign Here, Standard Business), with appearance streams; replies, status, checkmarks, locking, move/resize/restyle/delete; properties dialog; panel filter and sort; hide all; summaries (comments only); XFDF/FDF import and export (partial imports preserve existing reply and review-status links; nested FDF export uses lazy array owners and annotation positions, with retained entries budgeted before cloning under copied-graph limits and source `/Page` and `/Pages` dictionaries replaced by null at every copy depth); flatten; Fill & Sign with adjustable text/date size; agent tools.
Done since: polygons, connected lines, clouds, callouts, inserted text, colour and checkmark filters; image signature pointer previews, selection handles and live image movement/resizing with proportional corners and independent edge handles. A refused restyle or resize of a text box another program drew leaves that comment unchanged (#1327). Make Current Properties Default on an arrow updates arrows, not plain lines (#1302). Flattening keeps a visible comment it cannot draw (#1317). Missing: custom stamps, replace-text proposals, summary layouts with the page | -| M6 | Forms + JavaScript | 160–320 | 50% | 40–75 | Done: filling all field types with regenerated appearances; Prepare a form (every field type, multi-select/shared properties, move/resize/delete, Field Properties General/Appearance/Position/Options/Format/Validate/Calculate); Acrobat's AF format/keystroke/validate/calculate functions and simplified field notation run natively in Acrobat's event order; tab order; push-button actions; flatten; agent tools. Form data exchange (FDF, XFDF, XML, CSV, text) done; XFDF values retain text across XML comments and processing instructions. Plain AcroForm XML imports retain all direct text around comments and processing instructions, including CDATA and character references. CSV export and spreadsheet merging quote tabs, and import distinguishes quoted tabs from TSV delimiters without changing field identities. XML/XFDF exports preserve tabs and line breaks in names and comment metadata. Refreshed against upstream `99941daa` (2026-10-15).
Done since: JavaScript engine (boa, sandboxed) running custom keystroke/validate/calculate/format and button scripts, document JavaScripts, console. Done since: Push-button normal labels are editable per widget through Options and form_set_props, independently of field names; rendering, undo/redo and incremental/full save/reopen are covered. (#2892). Missing: Actions tab, wider object model (annotations, layers, dialogs), XFA
Done since: Multi-select choice fields write ascending `/I` option indices while preserving `/V` selection order; synthetic forms/engine regressions cover reverse selection and save/reopen. CSV export preserves carriage returns in names and values.
Done since: Text field table: an area divided into rows and columns of named text fields, added as one undoable edit, with `form_add_field_table`; copying an existing field into a grid remains. Form detection preserves comments across content streams and does not add fields over rectangles hidden by those comments. PR #2279 refreshed on main: field highlighting defaults on, stored choices are retained; secured-form toggle expectations updated. CI validation pending; estimates unchanged. | +| M6 | Forms + JavaScript | 160–320 | 50% | 40–75 | Done: filling all field types with regenerated appearances; Prepare a form (every field type, multi-select/shared properties, move/resize/delete, Field Properties General/Appearance/Position/Options/Format/Validate/Calculate); Acrobat's AF format/keystroke/validate/calculate functions and simplified field notation run natively in Acrobat's event order; tab order; push-button actions; flatten; agent tools. Form data exchange (FDF, XFDF, XML, CSV, text) done; XFDF values retain text across XML comments and processing instructions. Plain AcroForm XML imports retain all direct text around comments and processing instructions, including CDATA and character references. CSV export and spreadsheet merging quote tabs, and import distinguishes quoted tabs from TSV delimiters without changing field identities. XML/XFDF exports preserve tabs and line breaks in names and comment metadata. Refreshed against upstream `99941daa` (2026-10-15).
Done since: JavaScript engine (boa, sandboxed) running custom keystroke/validate/calculate/format and button scripts, document JavaScripts, console. Done since: Push-button normal labels are editable per widget through Options and form_set_props, independently of field names; rendering, undo/redo and incremental/full save/reopen are covered. (#2892). Missing: Actions tab, wider object model (annotations, layers, dialogs), XFA
Done since: Multi-select choice fields write ascending `/I` option indices while preserving `/V` selection order; synthetic forms/engine regressions cover reverse selection and save/reopen. CSV export preserves carriage returns in names and values.
Done since: Text field table: an area divided into rows and columns of named text fields, added as one undoable edit, with `form_add_field_table`; copying an existing field into a grid remains. Form detection preserves comments across content streams and does not add fields over rectangles hidden by those comments. PR #2279 refreshed on main: field highlighting defaults on, stored choices are retained; secured-form toggle expectations updated. CI validation pending; estimates unchanged.
Prepare a form copies text fields and check boxes into independent grids (other field types remain). | | M6 | Forms + JavaScript | 160–320 | 50% | 40–75 | Done: filling all field types with regenerated appearances; Prepare a form (every field type, multi-select/shared properties, move/resize/delete, Field Properties General/Appearance/Position/Options/Format/Validate/Calculate); Acrobat's AF format/keystroke/validate/calculate functions and simplified field notation run natively in Acrobat's event order; tab order; push-button actions; flatten; agent tools. Form data exchange (FDF, XFDF, XML, CSV, text) done; XFDF values retain text across XML comments and processing instructions. Plain AcroForm XML imports retain all direct text around comments and processing instructions, including CDATA and character references.
Done since: JavaScript engine (boa, sandboxed) running custom keystroke/validate/calculate/format and button scripts, document JavaScripts, console. Missing: Actions tab, wider object model (annotations, layers, dialogs), XFA
Done since: Multi-select choice fields write ascending `/I` option indices while preserving `/V` selection order; synthetic forms/engine regressions cover reverse selection and save/reopen. CSV export preserves carriage returns in names and values. | | M6 | Forms + JavaScript | 160–320 | 50% | 40–75 | Done: filling all field types with regenerated appearances; Prepare a form (every field type, multi-select/shared properties, move/resize/delete, Field Properties General/Appearance/Position/Options/Format/Validate/Calculate); Acrobat's AF format/keystroke/validate/calculate functions and simplified field notation run natively in Acrobat's event order; tab order; push-button actions; flatten; agent tools. Form data exchange (FDF, XFDF, XML, CSV, text) done; XFDF values retain text across XML comments and processing instructions. XML/XFDF exports preserve tabs and line breaks in names and comment metadata. Refreshed against upstream `99941daa` (2026-10-15).
Done since: JavaScript engine (boa, sandboxed) running custom keystroke/validate/calculate/format and button scripts, document JavaScripts, console. Missing: Actions tab, wider object model (annotations, layers, dialogs), XFA
Done since: Multi-select choice fields write ascending `/I` option indices while preserving `/V` selection order; synthetic forms/engine regressions cover reverse selection and save/reopen. CSV export preserves carriage returns in names and values. | | M6 | Forms + JavaScript | 160–320 | 50% | 40–75 | Done: filling all field types with regenerated appearances; Prepare a form (every field type, multi-select/shared properties, move/resize/delete, Field Properties General/Appearance/Position/Options/Format/Validate/Calculate); Acrobat's AF format/keystroke/validate/calculate functions and simplified field notation run natively in Acrobat's event order; tab order; push-button actions; flatten; agent tools. Form data exchange (FDF, XFDF, XML, CSV, text) done; XFDF values retain text across XML comments and processing instructions. XML/XFDF exports preserve tabs and line breaks in names and comment metadata. Plain AcroForm XML imports retain all direct text around comments and processing instructions, including CDATA and character references. CSV export and spreadsheet merging quote tabs, and import distinguishes quoted tabs from TSV delimiters without changing field identities.
Done since: JavaScript engine (boa, sandboxed) running custom keystroke/validate/calculate/format and button scripts, document JavaScripts, console. Missing: Actions tab, wider object model (annotations, layers, dialogs), XFA
Done since: Multi-select choice fields write ascending `/I` option indices while preserving `/V` selection order; synthetic forms/engine regressions cover reverse selection and save/reopen. CSV export preserves carriage returns in names and values. | @@ -288,6 +290,8 @@ M2 (renderer), M7 (content editing), M10 (OCR and Office), M11 (Preflight and st ## Revision history +**2026-11-03 · minor:** M6: an existing text field or check box can be copied into an independently named grid from Prepare a form or `form_add_field_table`. Further field types remain; estimates unchanged. + **2026-10-26 · patch:** M2/PR #4172: reconcile current main and preserve upstream Japanese serif/weight selection alongside the installed CJK viewer and preview fallback. Estimates unchanged. **2026-10-25 · minor:** M14 localization current state: Arabic catalogs stay logical, Arabic/Kurdish labels take an explicit RTL direction, and stock chrome mirrors; native/browser RTL input, IME and complex workflows remain unqualified. Native Simplified Chinese uses LXGW WenKai Lite; the web build has no Hans face. Estimates unchanged. diff --git a/parity/acrobat-features.toml b/parity/acrobat-features.toml index 8b7ac909a0..b03fb96989 100644 --- a/parity/acrobat-features.toml +++ b/parity/acrobat-features.toml @@ -5159,8 +5159,11 @@ evidence = [ "crates/engine/src/field_table.rs::a_table_is_added_and_undone_as_one_step", "crates/automation/tests/it/automation.rs::adding_a_field_table_through_tools", "crates/ui-egui/tests/it/prepare.rs::a_text_field_table_is_drawn_set_up_and_added_in_one_step", + "crates/forms/src/tests.rs::grid_copy_preserves_properties_and_has_an_independent_value", + "crates/automation/tests/it/automation.rs::copying_a_field_into_a_grid_through_tools", + "crates/ui-egui/tests/it/prepare.rs::copying_a_field_into_a_grid_from_its_context_menu", ] -notes = "Prepare a form ▸ Text field table: drag an area, then set rows, columns, spacing, column widths (draggable dividers) and a name pattern per column in a movable window, with the table previewed on the page. Added as one undoable edit, or refused whole with the reason (a cell under 4 pt, a name with a period, a repeated or existing name); form_add_field_table does the same headlessly. Missing: copying an existing field of any type, with its properties, into a grid from its context menu, which is what this entry describes; the table only creates new text fields." +notes = "Prepare a form ▸ Text field table: drag an area, then set rows, columns, spacing, column widths (draggable dividers) and a name pattern per column in a movable window, with the table previewed on the page. Added as one undoable edit, or refused whole with the reason (a cell under 4 pt, a name with a period, a repeated or existing name). Create Multiple Copies in a text field or check box's context menu uses the same grid to copy its properties and initial value into independently named fields; form_add_field_table can do the same with source_field. Missing: copying radio groups, choice fields, buttons, signatures and check boxes with per-widget export values." [[feature]] id = "form.rename-lock-fields"