Module: Pdfrb::Compare
- Defined in:
- lib/pdfrb/compare.rb,
lib/pdfrb/compare/report.rb,
lib/pdfrb/compare/comparator.rb
Overview
Semantic PDF comparison. Compares two PDFs at the structural level: page count, per-page extracted text, font inventory, image count, outline structure, and metadata. Returns a structured report.
Designed for regression testing: "did our render change from yesterday's reference?" Not a pixel diff — that's a separate concern (rasterize + image compare).
Defined Under Namespace
Classes: Comparator, Report
Class Method Summary collapse
-
.compare(left, right) ⇒ Pdfrb::Compare::Report
Compare two PDFs.
-
.equivalent?(left, right) ⇒ Boolean
Convenience: returns true if the two PDFs are equivalent.
- .to_document(input) ⇒ Object
Class Method Details
.compare(left, right) ⇒ Pdfrb::Compare::Report
Compare two PDFs. Accepts bytes, IO, or Document objects.
22 23 24 25 26 |
# File 'lib/pdfrb/compare.rb', line 22 def compare(left, right) left_doc = to_document(left) right_doc = to_document(right) Comparator.new.compare(left_doc, right_doc) end |
.equivalent?(left, right) ⇒ Boolean
Convenience: returns true if the two PDFs are equivalent.
29 30 31 |
# File 'lib/pdfrb/compare.rb', line 29 def equivalent?(left, right) compare(left, right).equivalent? end |
.to_document(input) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/pdfrb/compare.rb', line 33 def to_document(input) case input when Pdfrb::Document then input when ::String then Pdfrb::Document.new(io: StringIO.new(input)) when IO, StringIO then Pdfrb::Document.new(io: input) else raise ArgumentError, "expected String, IO, or Document" end end |