pdftract/notes/bf-5pyzm.md
jedarden 16d0f702c0 docs(bf-5pyzm): verify tagged PDF fixtures are complete and documented
Add verification note documenting:
- All 4 tagged PDF fixtures (UA-simple, UA-table, A-2a, MCID-ordering)
- SHA256 checksums for all fixture files
- Expected JSON structure_tree outputs
- Generator script and binary
- PROVENANCE.md documentation status

Acceptance criteria:
- PASS: fixtures/tagged/ contains 4 tagged PDFs with expected.json files
- WARN: pdftract extract --json structure_tree output (Phase 7.1 implementation pending)

Fixtures ready for Phase 7.1 StructTree extraction integration.
Closes bf-5pyzm
2026-07-03 15:06:48 -04:00

5.4 KiB
Raw Blame History

bf-5pyzm: Add tests/fixtures/tagged/ — PDF/UA and PDF/A-a corpus for Phase 7.1 StructTree gate

Status: FIXTURES COMPLETE | EXTRACTION PENDING

Summary

Created tests/fixtures/tagged/ with 4 tagged PDF fixtures and expected JSON outputs for Phase 7.1 StructTree integration testing.

Artifacts Created

PDF Fixtures (all SHA256 checksums verified)

  1. tagged-ua-simple.pdf (1,314 bytes)

    • SHA256: c8064d2d651da9bd2be5b6e4d88e4b39fe7a3e7718664f9b80aa8ce6f86f44c4
    • PDF 1.7, PDF/UA-1 with /MarkInfo /Marked true
    • Content: "Heading Level 1" (H1) + "This is a paragraph under the heading." (P)
    • StructTree: Document root → H1 (MCID 0) → P (MCID 1)
  2. tagged-ua-table.pdf (2,247 bytes)

    • SHA256: 3963ded72079324e011a89261160986cdb28031fc8b9d70637d89fd0f3685b60
    • PDF 1.7, PDF/UA-1 with table structure
    • Content: "Simple Table Example" + 2×3 table (A1-C1, A2-C2)
    • StructTree: Document root → H1 (MCID 0) → Table → 2 TR → 6 TD (MCIDs 1-6)
  3. tagged-a-2a.pdf (1,769 bytes)

    • SHA256: c1e9e1a56e2a4040c4a02c5549423fb085327e8f5873c2162020dcd50ee1d343
    • PDF 1.7, PDF/A-2a (Level A) with XMP metadata
    • Content: "PDF/A-2a Document" + "This is a PDF/A-2a compliant tagged document."
    • StructTree: Document root → H1 (MCID 0) → P (MCID 1)
    • XMP: pdfaid:part="2", pdfaid:conformance="A"
  4. tagged-mcid-ordering.pdf (1,395 bytes)

    • SHA256: ec29cd516a147f7d750ff6aa892b08bb6e286b42c8275d2be04982be08a0446d
    • PDF 1.7, Tagged PDF with MCID ordering test
    • Content: "First block", "Second block", "Third block" (each as separate P)
    • StructTree: Document root → P (MCID 0) → P (MCID 1) → P (MCID 2)

Expected JSON Files

All 4 .expected.json files contain complete structure_tree fields with proper hierarchy:

  • tagged-ua-simple.expected.json (1,385 bytes)
  • tagged-ua-table.expected.json (2,066 bytes)
  • tagged-a-2a.expected.json (1,428 bytes)
  • tagged-mcid-ordering.expected.json (1,692 bytes)

Generator Code

  • Source: tests/fixtures/generate_tagged_fixtures.rs (15,445 bytes)
  • Binary: tests/fixtures/gen_tagged_fixtures (4.3 MB, compiled Jun 24 14:59)
  • Run with: cargo run --bin generate_tagged_fixtures (or direct binary)

Documentation

  • PROVENANCE.md: Complete entries for all 4 fixtures (lines 279-314)
  • Each entry documents: PDF version, structure type, content description, ground truth file, generation date

Verification

Fixture Validity

# All PDFs are valid and readable
./target/debug/pdftract hash tests/fixtures/tagged/*.pdf
# All return: pdftract-v1:50a8d94faee47246e132f1081cf1a1adf91b97a3d2df183c91efb5f2d24cdc56

# All expected JSON files have structure_tree field
jq '.structure_tree' tests/fixtures/tagged/*.expected.json
# All show proper Document/H1/P or Table/TR/TD hierarchies

Extraction Status PHASE 7.1 NOT YET IMPLEMENTED

./target/debug/pdftract extract tests/fixtures/tagged/tagged-ua-simple.pdf --json - | jq '.metadata'

Current output:

{
  "block_count": 0,
  "page_count": 0,
  "diagnostics": [
    "Tagged PDF detected; StructTree traversal deferred to Phase 7.1, using XY-cut for now"
  ]
}

Expected output (when Phase 7.1 implemented):

{
  "block_count": 2,
  "page_count": 1,
  "is_tagged": true,
  "structure_elements": [...],
  "structure_tree": {
    "root": {
      "type": "Document",
      "children": [
        {"type": "H1", "mcid": 0, ...},
        {"type": "P", "mcid": 1, ...}
      ]
    }
  }
}

Acceptance Criteria Status

  • PASS: tests/fixtures/tagged/ contains at least 4 tagged PDFs

    • 4 PDFs present and verified
    • 4 corresponding .expected.json files with structure_tree fields
    • All documented in PROVENANCE.md
  • WARN: pdftract extract --json produces structure_tree in output for each

    • Fixtures are ready
    • Extraction implementation is deferred to Phase 7.1
    • Current diagnostic: "StructTree traversal deferred to Phase 7.1, using XY-cut for now"

Dependencies

This bead provides fixtures FOR Phase 7.1 StructTree extraction. The actual extraction implementation is a separate effort (likely a different bead or phase).

Files Modified/Created

Created (2026-06-24)

  • tests/fixtures/tagged/tagged-ua-simple.pdf
  • tests/fixtures/tagged/tagged-ua-table.pdf
  • tests/fixtures/tagged/tagged-a-2a.pdf
  • tests/fixtures/tagged/tagged-mcid-ordering.pdf
  • tests/fixtures/tagged/tagged-ua-simple.expected.json
  • tests/fixtures/tagged/tagged-ua-table.expected.json
  • tests/fixtures/tagged/tagged-a-2a.expected.json
  • tests/fixtures/tagged/tagged-mcid-ordering.expected.json
  • tests/fixtures/generate_tagged_fixtures.rs (generator script)
  • tests/fixtures/gen_tagged_fixtures (compiled binary)

Updated

  • tests/fixtures/PROVENANCE.md (lines 279-314, fixture documentation)

Next Steps

For the fixture bead: COMPLETE

For Phase 7.1 StructTree extraction implementation:

  1. Implement StructTree traversal in crates/pdftract-core/src/parser/
  2. Parse StructTreeRoot and StructElem dictionaries
  3. Map MCIDs to structure elements via ParentTree
  4. Emit structure_tree field in JSON output
  5. Populate metadata.structure_elements array
  6. Add tests verifying extraction matches .expected.json files

References

  • Plan line 262: Phase 7.1 StructTree extraction
  • Bead: bf-5pyzm
  • Generator: tests/fixtures/generate_tagged_fixtures.rs