mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-30 13:08:48 -06:00
M6: Merge data files into spreadsheet (FDF, XFDF, filled PDF forms → CSV); form_merge_data tool
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9321864393
commit
6ff0bf8f64
@@ -201,6 +201,7 @@ pub const COMMANDS: &[CommandSpec] = &[
|
||||
c("comment.summarize", "Summarize comments", None, None, HasComments, "file-text"),
|
||||
c("form.import_data", "Import form data…", None, None, HasFields, "file-input"),
|
||||
c("form.export_data", "Export form data…", None, None, HasFields, "file-output"),
|
||||
c("form.merge_data", "Merge data files into spreadsheet…", None, None, Nothing, "file-spreadsheet"),
|
||||
c("form.flatten", "Flatten form fields", None, None, HasFields, "layers"),
|
||||
c("form.prepare", "Prepare a form", None, None, Modification, "text-cursor-input"),
|
||||
c("form.tab_order.row", "Tab order: by rows", None, None, HasFields, "rows-3"),
|
||||
|
||||
@@ -82,6 +82,14 @@ pub use printcraft_sign as sign;
|
||||
pub use printcraft_sign::{SignOptions, SignatureInfo, Status as SignatureStatus, TrustStore};
|
||||
pub use printcraft_xfdf::Format as DataFormat;
|
||||
|
||||
/// Forms ▸ Merge data files into spreadsheet: the field values of each file (FDF, XFDF or a
|
||||
/// filled-in PDF form), as CSV with one row per file.
|
||||
pub fn merge_data_files(files: &[(String, Vec<u8>)]) -> Result<String, String> {
|
||||
let rows =
|
||||
files.iter().map(|(name, bytes)| printcraft_xfdf::data_values(bytes).map_err(|e| format!("{name}: {e}"))).collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(printcraft_xfdf::merge_csv(&rows))
|
||||
}
|
||||
|
||||
pub type SplitPart = (usize, usize, Arc<Vec<u8>>);
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
Reference in New Issue
Block a user