SShortSingh.
Back to feed

Comparing Two PDF Contract Versions Word by Word with Python

0
·3 views

PDFs have no built-in change tracking, so comparing two versions of a contract means computing the difference between the files. The article weighs three approaches: pixel-level comparison of rendered pages, line-by-line comparison of extracted text, and word-level comparison. It tests all three on a fictional design-services contract that returns with five changes, including a payment deadline moved from 30 to 60 days and altered revision and ownership terms. A reformatted copy containing identical words was also tested to see which method is robust to layout changes. Word-level diffing, implemented in about 120 lines of Python using PyMuPDF and difflib, detected the same five changes in both files, while pixel and line diffs were thrown off by reflowed text. The method also writes the changes back into the PDF as comments.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingHacker News ·

FAA Begins Retiring Decades-Old Floppy Disks From Air Traffic Control Systems

The Federal Aviation Administration has started phasing out floppy disks that have been used in air traffic control operations for decades. Announced by Transportation Secretary Sean P. Duffy, the move is part of a broader effort to modernize aging agency technology. The article provided is only a link to an FAA newsroom release, so details such as the exact timeline, number of systems affected, and replacement technology are not available here. The story was shared on Hacker News, where it drew modest engagement.

0
ProgrammingDEV Community ·

Unchanged 39-of-40 test score hid a shift in which CSV parser case failed

An AI developer built 40 CSV fixtures with literal expected results and ran them through the csv-parse 6.1.0 library via a custom policy adapter. Under default settings one quote-handling case disagreed with its expectation, and relaxing quote handling fixed that case but broke another, so the score stayed at 39 of 40. The author kept the expectations fixed and documented both mismatches, arguing that matching pass totals can conceal a changed behavior contract. The piece recommends recording file acceptance or rejection, exact returned values such as leading-zero identifiers, and parser configuration separately from application import policy. It also notes that the injected-fault and cross-implementation checks give only partial assurance and do not cover production databases or security.

0
ProgrammingDEV Community ·

How Social Engineering Exploits Human Psychology and How to Defend Against It

Social engineering is a cybersecurity threat that targets people rather than software, using psychological manipulation to get victims to reveal confidential information or take harmful actions. Attackers often gather information about their targets first to make their deceptions more believable. Common tactics include creating false emergencies that pressure victims into acting quickly, and pretexting, where the attacker impersonates a trusted authority such as IT staff or an executive. Physical methods like baiting, for example leaving infected USB drives in workplaces, also exploit curiosity to bypass technical defenses. The article uses concrete workplace scenarios to show how these manipulations operate and how individuals can recognize them.

0
ProgrammingDEV Community ·

Why a Typeahead Trie Should Store the Top 10 Completions at Every Node

A system design interview question about search autocomplete asks what a service does when a user types a single character. The naive approach of collecting and sorting every query under a prefix's subtree on each keystroke is correct but too slow at scale. Latency limits of about 0.1 seconds, including network time, make precomputation necessary. Illustrative capacity estimates show reads vastly outnumber writes and that client-side debouncing and caching can cut request volume roughly fourfold. The recommended fix is to precompute the top 10 completions at every trie node during build time, so each lookup only walks the prefix and returns a ready list.