pdf.structural_diff
result = pdf.structural_diff(src_a, src_b)
Input: src_a, src_b · Output: result
What it is
A coarse, non-content comparison: page count, per-page /MediaBox size, whether each document has an outline (/Outlines) and each document's total annotation count.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = pdf.structural_diff(src_a, src_b) | src_a —not documented yetsrc_b —not documented yet | pages_b NumNumdiffering_dimensions List, Record, or NumList of Records only for pages whose size differs or that exist on only one side, each with page (Num) and a/b — a Record {width, height} in PDF points, or none when that side lacks the pagebookmarks_b —Boolannotations_b NumNum | Returns a Record: pages_a, pages_b (Num), differing_dimensions (List of Records only for pages whose size differs or that exist on only one side, each with page (Num) and a/b — a Record {width, height} in PDF points, or none when that side lacks the page), bookmarks_a/bookmarks_b (Bool) and annotations_a/annotations_b (Num). Deliberately shallow — bookmark-by-bookmark or annotation-by-annotation comparison is a larger feature this does not attempt. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
import pdf
# Only `subject` changes; title/author/producer/... are untouched.
tagged = pdf.set_metadata("paper.pdf", subject = "Impedance spectroscopy")
pdf.write_merge("tagged.pdf", [tagged]) # or write it out any other way
hits = pdf.find_text("paper.pdf", "impedance", case_sensitive = false)
for h in hits
print("page {h.page}, offset {h.offset}")
end
d = pdf.text_diff("draft_v1.pdf", "draft_v2.pdf")
print("{length(d.differing_pages)} of {d.pages_b} pages changed")
s = pdf.structural_diff("draft_v1.pdf", "draft_v2.pdf")
if s.pages_a != s.pages_b
print("page count changed: {s.pages_a} -> {s.pages_b}")
end
not run by the build — this one needs something the repository cannot supply · from file-io