mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-14 19:27:04 -04:00
Japanese forms often name a check box's on state in Shift-JIS (「はい」 is /#82#CD#82#A2). State names were read with from_utf8_lossy, so ticking such a box wrote a different name to /AS and /V, no appearance matched, and the box was drawn with no mark (or not at all). Names now map to text losslessly (forms::name_text / name_bytes: UTF-8 as itself, other bytes and `#` as #XX) wherever states and values are read and written: /V, /DV and /AS, PdfCraft's own state appearances, and FDF import and export, so such values also survive an FDF or XFDF round trip. Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Brandon Thomas <[email protected]>
pdfcraft-xfdf
Layer L4: comment and form data exchange (execution plan M5.6, M6.7).
let xml = export_xfdf(&doc, true, true, "form.pdf"); // comments and/or field values
let fdf = export_fdf(&doc, false, true, "form.pdf");
let txt = export_data(&doc, Format::Txt); // or Xml, Csv
let report = import(&mut doc, &bytes)?; // XFDF, FDF, XML, CSV or text, detected
- XFDF (ISO 19444-1): every comment type PdfCraft knows (text, free text, line, square,
circle, polygon, polyline, markup, stamp, caret, ink, attachments, sound, redact) with rect,
name, author, subject, dates, flags, colours, opacity, width, icon, quads, line ends, ink,
default appearance, pop-ups and reply threads (
inreplyto); field values nested by name. - FDF: fields (with
/Kidshierarchies) and comments as direct objects. - Form data: Acrobat's XML (
xfdf:originalkeeps names that aren't XML names), CSV and tab-delimited text (a row of names, a row of values).
Import replaces comments with the same /NM, draws appearances PdfCraft can draw, and sets
values through the form's own checks (formats, validation, recalculation); read-only fields take
imported values, as in Acrobat. XML is read with roxmltree.