# Detect an Edited Bank Statement PDF: 980 Files Tested

> We edited 600 generated bank statements 12 ways. Eight checks caught 511, with 7 false alarms on 380 genuine files. Edits that kept the math passed.

**In short:** In PyMuPDF 1.26.5 and Tesseract 5.5.2 tests on 980 generated bank statement PDFs (380 genuine files in six made-up layouts, and 600 copies edited 12 different ways, 50 per method), eight checks in one Python script caught 511 of the 600 edits and flagged 7 of the 380 genuine files, all of them scans with misread digits. Edits caught per check: producer 214, dates 300, revisions 100, fonts 244, overlap 100, alignment 145, OCR text layer 39, running balance 235. Counting %%EOF markers would have flagged all 40 genuine files from a layout that appends an update after creation; comparing the page content of the first revision with the final file flagged none of them and caught all 100 edits saved on top. A strict list of each bank's known Producer flagged all 40 genuine statements a customer printed to PDF. The balance check caught 229 of 252 edits that broke the math and, apart from 4 misread digits on scans, none of the 255 edits that fixed every later balance and total. The 89 misses left no trace of an editing tool: numbers rewritten in the page's own text commands with metadata restored (26 of 50), a clone of the bank's own template (25 of 50), a painted scan printed and rescanned (31 of 50), and same font edits on layouts with standard fonts (7 of 50). These are generated files and scripted edits, not DocsAPI results.

**Canonical URL:** https://docsapi.co/resources/blogs/detect-edited-bank-statement-pdf
**Author:** Nupura Ughade — Content Marketing Lead, DocsAPI
**Author LinkedIn:** https://www.linkedin.com/in/nupura-ughade/
**Published:** 2026-11-27T00:00:00.000Z
**Updated:** November 27, 2026
**Primary topic:** detect edited bank statement pdf
**Site:** https://docsapi.co (DocsAPI — Document AI & OCR API for SMB Lending)

---

To find out whether a bank statement PDF was edited, run several checks, because each one sees a different trace. Metadata shows the tool, the file's revision history shows a save on top, fonts and alignment show a replaced number, and the running balance shows broken math.

In our test on 600 edited copies of generated statements, made 12 different ways, eight checks caught 511 between them. They raised 7 false alarms on 380 genuine statements, all of them scans. The 89 edits that got through left no trace of an editing tool, and 82 of them kept the arithmetic right.

No single check came close to that total. The best content check, fonts, caught 244 of the 600, and the balance check caught 235, nearly all of them edits that left the math broken. This guide adds numbers to our earlier pieces: [bank statement fraud detection](/resources/blogs/bank-statement-fraud-detection) explains why the file's structure is harder to scrub than its metadata, and [document fraud detection API](/resources/blogs/document-fraud-detection-api) lists the checks a fraud pipeline runs. Below are the test, which check caught which edit, the false alarms, the edits nothing caught, and the script.

## How do you tell if a bank statement PDF was edited?

Read the file in eight ways and look for any one that disagrees with a clean export from a bank. The table lists the checks the script runs, with how many of the 600 edited files each one caught and how many of the 380 genuine files it flagged.

| Check | What fires it | Edited files caught (of 600) | Genuine files flagged (of 380) |
| --- | --- | --- | --- |
| Producer | Producer or Creator names an editing or office tool, or the XMP copy of the metadata disagrees | 214 | 0 |
| Dates | Modified more than a minute after it was created, or the XMP date disagrees | 300 | 0 |
| Revisions | An earlier revision inside the file shows different page text, notes or images | 100 | 0 |
| Fonts | A second copy of a font on one page, a number whose font or size differs from its column, or a font used for only one or two pieces of text | 244 | 0 |
| Overlap | Text under a box drawn after it, text on top of other text, or an annotation over text | 100 | 0 |
| Alignment | A number more than 0.6 points off its column's right edge, or more than 0.5 points off its row | 145 | 0 |
| OCR layer | On a scan, the hidden text says one number and two OCR reads of the image agree on another | 39 | 1 |
| Balance | Running balance, carried forward balance or summary totals do not add up | 235 | 6 |
| Any of the eight |  | 511 | 7 |

The first three checks read the file's records about itself, so they are fast and easy to fool. The next three read the text as drawn on the page. The last two compare the page with itself: the hidden text with the image, and each balance with the one before it.

When any check fires, a person should look at the statement with the reason in hand. When none fires, the file is not proven genuine, as the misses below show.

## How did we test it?

We wrote a generator for six made-up bank layouts, then edited copies of its statements in ways a person might. Every file, change and seed is recorded, and the checks never saw that record. The layouts differ in the ways real exports do:

- Fonts: Arial, Georgia, Verdana and Courier New embedded in the file, and Times and Helvetica as standard fonts that are not embedded.
- Design: a dark header band with white text on one layout, light bands and striped rows on others, plain ruled tables on the rest.
- Columns: separate withdrawal and deposit columns on four layouts, one signed amount column on two, with minus signs on one and parentheses on the other.
- Length: 12 to 58 transactions on one or two pages, with an account summary box on page 1.

The genuine set held 380 files of four kinds. There were 240 bank exports, 40 per layout, and one layout's process appends a small update to every file after creating it, as a stamping or signing step can.

There were also 40 statements a customer printed to PDF from a browser or viewer, 60 scans with a hidden OCR text layer, and 40 scans with no text at all. Scans were rendered at 300 DPI with light blur, sensor noise and JPEG compression.

The edited set held 600 files, 50 for each of 12 methods, each made from a fresh genuine statement. Each edit made one of three changes.

In 252 files one deposit went up by $500 to $5,000 and nothing else changed, so the math broke. In 255 the same raise came with every later balance and the summary totals fixed. In 93 the account holder's name changed.

We tuned every threshold on a separate development set of 296 files, then froze the script and ran it once on the 980 test files reported here. The tools were PyMuPDF 1.26.5 and Tesseract 5.5.2. These are our own tests with open source tools, not a DocsAPI result.

## What were the 12 ways of editing?

Ten methods started from a text PDF as a bank exports it and two from a scan. They run from careless to careful. The last column says which traces each method leaves by design, which matters for reading the results.

| Method | What the edit does | Tool traces left by design |
| --- | --- | --- |
| 1. Font swap, appended save | Removes the number and types the new one in Helvetica at the same start point, then saves the change on top of the original | Later ModDate, a second revision; Producer unchanged |
| 2. Font swap, online editor | The same edit, but the whole file is rewritten | Editor's name as Producer, later ModDate |
| 3. Same font, PDF toolkit | Types the new number in the statement's own font, right aligned, and rewrites the file | A toolkit Producer no editor list holds, later ModDate |
| 4. Same font, metadata restored | As method 3, then copies the original Producer, Creator and dates back | None |
| 5. Numbers rewritten in place | Changes the digits inside the page's own text commands, same font object, right edge kept, metadata restored | None |
| 6. White box and text | Draws a box in the background color over the number and types a new one on top by eye | Editor's name as Producer, later ModDate |
| 7. White text box note | Adds a text box annotation with a filled background over the number, saved on top of the original | Later ModDate, a second revision |
| 8. Image rebuild | Renders each page at 200 DPI, paints over the number, saves the images as a new PDF | Image tool's name as Producer |
| 9. Retyped in a word processor | Rebuilds the whole statement in a different font | Word processor's name as Producer |
| 10. Template clone | Rebuilds the statement with the bank's own layout, fonts, Producer and dates | None |
| 11. Scan painted, text layer kept | Paints the new number onto the scan image and leaves the hidden OCR text as it was | Later ModDate |
| 12. Scan painted, printed and rescanned | Paints the number, then makes a new scan with fresh OCR text and fresh scanner metadata | None |

So the producer and dates checks score full marks or zero on most methods because of how we built each method, not because of anything we measured. Real editors differ by product and version, and we did not test any named tool. The content checks are where the counts tell you something.

## Which checks caught which edits?

Each row is 50 files. The middle column counts the files on which each check fired; checks that never fired on that method are left out.

| Method | Checks that fired (files of 50) | Caught by any |
| --- | --- | --- |
| 1. Font swap, appended save | dates 50, revisions 50, fonts 42, alignment 35, balance 17 | 50 |
| 2. Font swap, online editor | producer 50, dates 50, fonts 43, alignment 30, balance 25 | 50 |
| 3. Same font, PDF toolkit | dates 50, fonts 29, balance 19, producer 14 | 50 |
| 4. Same font, metadata restored | fonts 33, balance 23 | 43 |
| 5. Numbers rewritten in place | balance 24 | 24 |
| 6. White box and text | producer 50, dates 50, fonts 50, overlap 50, alignment 42, balance 16 | 50 |
| 7. White text box note | dates 50, revisions 50, overlap 50, fonts 47, alignment 38, balance 22 | 50 |
| 8. Image rebuild | producer 50, balance 10 | 50 |
| 9. Retyped in a word processor | producer 50, balance 21 | 50 |
| 10. Template clone | balance 25 | 25 |
| 11. Scan painted, text layer kept | dates 50, OCR layer 38, balance 15 | 50 |
| 12. Scan painted, printed and rescanned | balance 18, OCR layer 1 | 19 |

Read the table by asking which trace each method could not avoid. A swap into a standard font leaves a font change, and a white box leaves text under it. Saving on top of the original leaves the first revision in the file, which still shows the old number.

Methods 5, 10 and 12 avoid all of that, so the balance check caught them almost only when the edit broke the math. Method 4 avoids the metadata traces too, but a second copy of an embedded font gave it away in 33 files.

Two counts need a word of caution. The one OCR layer flag on method 12 was a misread, not the edit, because a rescan gives the image and its text layer the same new number. And 6 of the balance flags on edits whose math was kept right also came from misread digits on scans. We count them as caught because a person would open the file, but the reason shown would have been the wrong one.

## Did the checks fire on genuine statements?

On text PDFs, no. The 240 bank exports and the 40 printed copies passed all eight checks. All seven false alarms were on scans.

| Genuine kind | Files | Flagged by any check | What fired |
| --- | --- | --- | --- |
| Bank export, six layouts | 240 | 0 | None. A plain count of saves would have flagged all 40 files from the layout that appends an update |
| Printed to PDF by the customer | 40 | 0 | None. A list of each bank's known Producer would have flagged all 40 |
| Scan with OCR text layer | 60 | 3 | Balance 2, OCR layer 1, all misread digits |
| Scan, image only | 40 | 4 | Balance 4, all misread digits |

The update count is the check most worth fixing. The [PDF specification](https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf) (ISO 32000-1, section 7.5.6) says a file "can be updated incrementally without rewriting the entire file", with changes appended and each update ending in its own %%EOF marker. A genuine issuer can do that too.

Counting %%EOF markers flagged all 40 files from our layout that appends an update after creation. Comparing the page text, notes and images of the first revision with the final file flagged none of them, and still caught all 100 edits saved that way.

The same section points to the limit. Every method except 1 and 7 wrote its file in one piece, which leaves one revision, so this check never fired on them. The structure argument in our [bank statement fraud detection](/resources/blogs/bank-statement-fraud-detection) piece holds only for edits saved on top of the original.

Printed copies are the next trap. A statement printed to PDF from a browser carries the browser's or the viewer's name as Producer. Our list of editing tools does not include print engines, so it stayed quiet.

A stricter rule that accepts only each bank's known Producer, learned from the development set, flagged all 40 printed copies. It also caught all 50 files from method 3, against 14 with the editor list alone, because a toolkit name is not an editor's name. Use the strict list for files that claim to come straight from online banking, and expect to explain it to customers who print.

On scans, OCR misreads look like edits. In the development set, before any guard, the OCR layer check alone flagged 7 of 20 genuine scans. The script now reads every number twice, once in the page and once cropped and enlarged, and treats a break as a misread when a low confidence cell or one wrong digit explains it. That left 6 balance and 1 OCR layer false alarms on the 100 genuine scans in the test.

On 15 of those 100 scans the balance check could not read enough of the table to judge, 12 of them on the Courier New layout. It reports those as not checked rather than as passed.

## What does each check catch, and what does it miss?

Fonts caught every font swap except on the layout that already used Helvetica, the editor's default. There, 15 swaps changed nothing a font check can see. For same font edits, the check caught every file whose bank embedded its fonts, because the editor embedded a second copy of the same font. It caught none of the 38 files from the two layouts with standard fonts, where the edit reused the font already there.

Overlap caught all 100 white box and annotation edits and never fired on a genuine file, even on layouts with shaded bands and striped rows. The rule that makes this work is draw order. A bank draws its shading first and its text on top, so a filled box drawn after the text it covers is a sign of an edit.

Alignment caught most edits placed by eye, and most edits typed at the old start point in a font of a different width. It missed every same font edit, because those were right aligned to the old edge. It also missed swaps between fonts with equal digit widths, such as Arial to Helvetica, unless a new number was longer than the old one, which happened in 10 of 30.

The OCR layer check caught 38 of 50 painted scans that kept their old text layer. Most misses were on the Courier New layout, where Tesseract could not read the numbers well enough to trust, and the guard against misreads stayed quiet. It cannot see an edit that was rescanned, because then the image and its text agree.

Balance caught edits that broke the math, and almost nothing else. Our test of [bank statement OCR errors](/resources/blogs/bank-statement-ocr-errors-balance-check) showed the same row by row check finding misread numbers. Here it finds edited ones, with the same blind spot for numbers changed in step.

## Is the balance check enough on its own?

Only against careless edits. The table splits the 600 edits by what changed.

| What the edit changed | Files | Balance check fired | Any check fired | Missed |
| --- | --- | --- | --- | --- |
| One deposit raised, nothing else | 252 | 229 | 245 | 7 |
| Deposit raised, later balances and totals fixed | 255 | 4 | 190 | 65 |
| Account holder's name | 93 | 2 | 76 | 17 |

On the 252 broken edits the balance check fired on 229. On text PDFs it fired on 202 of 208, and the 6 it missed were image rebuilds, 5 of them where OCR could not read enough of the table. The 6 flags among the other 348 edits were misreads.

So arithmetic catches the edits that forgot to fix the math, and the other seven checks catch the tool that made the edit. An edit that fixes the math and leaves no tool trace passes both.

## Which edits got past every check?

The 89 misses came from four methods. In 82 of them the edit kept the math right:

- Numbers rewritten in place: 26 of 50, every one that changed balances in step or changed only the name.
- Template clone: 25 of 50, again every edit with consistent math or a name change.
- Scan painted, printed and rescanned: 31 of 50. That includes 7 that broke the math, where the balance check could not read the table (4) or took a one digit change for a misread (3).
- Same font, metadata restored: 7 of 50, all on the two layouts with standard fonts.

Nothing these checks read separates these files from genuine ones, because most of them are clean files carrying false numbers. The template clone is the clearest case. It used the bank's layout, fonts, Producer and dates, so every check that compares the file with the bank's own output agreed with it. Catching these takes evidence from outside the file, such as the bank's own data.

## The script

One Python file runs all eight checks on a PDF and prints the ones that fired, with the reason. It needs PyMuPDF (`pip install pymupdf`). The OCR layer check, and the balance check on scans, also need the `tesseract` command line tool. Run it like this:

```
python3 check_statement.py statement.pdf python3 check_statement.py statement.pdf --known producers.json # strict Producer list per bank python3 check_statement.py statement.pdf --no-ocr --json # skip tesseract, print everything
```

We ran it on one of the test files, edited with a white box over a deposit. It printed this:

```
statement_edited.pdf: 2 page(s), 0 scanned, 1 revision(s), Producer "EasyPDF Edit 11.0.2" FIRED producer: Producer "EasyPDF Edit 11.0.2" names an editing or office tool Creator "EasyPDF Edit 11.0.2" names an editing or office tool Producer is "EasyPDF Edit 11.0.2" but the XMP copy says "DocGen Core 4.0.2" Creator is "EasyPDF Edit 11.0.2" but the XMP copy says "Dunmore Digital Statements" FIRED dates: modified 10 days, 18:54:28 after it was created (2026-04-04 21:54 to 2026-04-15 16:49) ModDate 2026-04-15 16:49 but the XMP copy says 2026-04-04 21:54 ok revisions FIRED fonts: 1 value(s) in the column ending at x=470 use a different font or size than the other 52 (Georgia 8.5): ['3,907.81'] font Helvetica is used for only 1 piece(s) of text: ['3,907.81'] FIRED overlap: page 1: "2,907.81" is hidden under a filled box drawn after it FIRED alignment: "3,907.81" ends +1.4 pt from its column edge n/a ocr FIRED balance: row "2026-03-18 ACH DEPOSIT PAYROLL CITY OF SPRINGFIELD 3,907.81 ": 5,310.49 +3,907.81 is not 8,218.30 summary deposits 13,541.85 but the rows add up to 14,541.85 6 of 8 checks fired: producer, dates, fonts, overlap, alignment, balance
```

We also ran it on a genuine export from another layout. Every check passed:

```
statement_genuine.pdf: 1 page(s), 0 scanned, 1 revision(s), Producer "StatementServer 6.1" ok producer ok dates ok revisions ok fonts ok overlap ok alignment n/a ocr ok balance 0 of 8 checks fired
```

It exits with code 1 when a check fires, so a pipeline can route those files to a person. In our runs a text PDF took about 0.1 seconds and a scanned page about 7 seconds, because of the two OCR passes.

The `--known` file maps a bank name, as printed on page 1, to the Producer strings its statements carry. Build it from statements you downloaded yourself, not from applicant files. Here is the whole script:

```
"""Check a bank statement PDF for signs of editing. Runs eight checks and prints the ones that fired, with the reason: producer Producer or Creator names an editing tool, or the two metadata copies disagree dates ModDate is more than a minute after CreationDate (or before it) revisions the file holds earlier revisions, and the page content differs between them fonts a second copy of a font on one page, a value whose font or size differs from its column, or a font family used by one or two pieces of text overlap text drawn under a later filled box, text on top of other text, or an annotation over text alignment a number off its column's right edge or off its row's baseline ocr on scanned pages, the hidden text layer disagrees with what OCR reads on the image balance running balances, carried forward balances and summary totals do not add up Usage: python3 check_statement.py statement.pdf [--known producers.json] [--no-ocr] [--json] producers.json maps a bank name, as printed on page 1, to the Producer strings its statements use. Needs PyMuPDF (pip install pymupdf). The ocr check, and balances on scanned pages, need the tesseract command line tool. Exit code 1 if any check fired, 0 if none did. """ import argparse import datetime as dt import json import re import statistics import subprocess import sys import pymupdf EDITOR = re.compile(r"(?([^|%s=\"([^\"]*)\"" % (tag, tag, tag), xmp or "") return (m.group(1) if m.group(1) is not None else m.group(3)).strip() if m else None def xmp_time(s): try: t = dt.datetime.fromisoformat(s.replace("Z", "+00:00")) return t.astimezone(dt.timezone.utc).replace(tzinfo=None) except (AttributeError, ValueError): return None # ---------- reading the page ---------- def words_from_trace(page): """Words with font, size, draw order and render mode, built from the characters PyMuPDF traces.""" out = [] for span in page.get_texttrace(): cur = [] for ch in list(span["chars"]) + [(32, 0, (0, 0), (0, 0, 0, 0))]: c = DASHES.get(chr(ch[0]), chr(ch[0])) gap = cur and ch[3][0] - cur[-1][3][2] > span["size"] * 0.3 if c in " \xa0" or gap: if cur: x0 = min(k[3][0] for k in cur) out.append(dict(text="".join(DASHES.get(chr(k[0]), chr(k[0])) for k in cur), x0=x0, y0=min(k[3][1] for k in cur), x1=max(k[3][2] for k in cur), y1=max(k[3][3] for k in cur), base=cur[0][2][1], font=span["font"], size=round(span["size"], 2), seq=span["seqno"], hidden=span["type"] == 3 or span.get("opacity", 1) == 0)) cur = [] if c in " \xa0" else [ch] else: cur.append(ch) return out def is_image_page(page): area = abs(page.rect) return any(abs(pymupdf.Rect(i["bbox"]) & page.rect) > 0.85 * area for i in page.get_image_info()) def ocr_words(page, dpi=300): """OCR one page with tesseract; boxes come back in PDF points.""" pix = page.get_pixmap(dpi=dpi, colorspace=pymupdf.csGRAY) w, h, sam = pix.width, pix.height, pix.samples lut = bytes(1 if i  0.5 * w for y in range(h)] y = 0 while y = 0: x, y, w, h = (int(v) * k for v in f[6:10]) text = "".join(DASHES.get(c, c) for c in f[11].strip()) out.append(dict(text=text, x0=x, y0=y, x1=x + w, y1=y + h, base=y + h, conf=float(f[10]))) merged = [] for o in out: # "17." + "377.87" is one number that OCR split in two if merged and re.fullmatch(r"\d{1,3}[.,]", merged[-1]["text"]) and re.fullmatch(r"\d{3}\.\d{2}", o["text"]) \ and abs(o["base"] - merged[-1]["base"])  0 and h > 0 and area > 0 else 0.0 def lines_of(words): lines = [] for w in sorted(words, key=lambda w: (w["base"], w["x0"])): tol = max(2.0, (w["y1"] - w["y0"]) * 0.45) if lines and abs(statistics.mean(v["base"] for v in lines[-1]) - w["base"])  60: why.append(f"modified {m - c} after it was created ({c:%Y-%m-%d %H:%M} to {m:%Y-%m-%d %H:%M})") if c and m and (c - m).total_seconds() > 1: why.append("ModDate is earlier than CreationDate") xm = xmp_time(xmp_value(xmp, "xmp:ModifyDate")) if xm and m and abs((xm - m).total_seconds()) > 60: why.append(f"ModDate {m:%Y-%m-%d %H:%M} but the XMP copy says {xm:%Y-%m-%d %H:%M}") return why def page_snapshot(doc): snap = [] for page in doc: words = sorted(page.get_text("words"), key=lambda w: (round(w[3]), w[0])) snap.append((tuple(w[4] for w in words), tuple(sorted((a.type[1], a.info.get("content", "")) for a in page.annots())), tuple(sorted(i["digest"].hex() for i in page.get_image_info(hashes=True))))) return snap def check_revisions(raw, doc): ends = [m.end() for m in re.finditer(rb"startxref\s+\d+\s+%%EOF[\r\n]*", raw)] info = {"revisions": len(ends), "content_changed": False} if len(ends)  8.0: groups.append(cur) cur = [] cur.append(x) if cur: groups.append(cur) centers = [statistics.mode(round(x, 1) for x in g) for g in groups if len(g) >= 3] cols = {c: [] for c in centers} for w in words: if centers: c = min(centers, key=lambda c: abs(c - w["x1"])) if abs(c - w["x1"])  1: main = max(styles, key=lambda k: len(styles[k])) odd = [w["text"] for k, v in styles.items() if k != main for w in v] why.append(f"{len(odd)} value(s) in the column ending at x={c:.0f} use a different font or size " f"than the other {len(styles[main])} ({main[0]} {main[1]}): {odd[:3]}") med = statistics.median(w["size"] for w in visible) fams = {} for w in visible: if 0.8 * med  w["seq"] and overlap_frac(w, box_of(d["rect"])) > 0.5] if covered: why.append(f'page {page.number + 1}: "{w["text"]}" is hidden under a filled box drawn after it') continue on_top = [v for v in shown if v is not w and v["seq"] > w["seq"] and v["text"] != w["text"] and overlap_frac(w, v) > 0.3] if on_top: why.append(f'page {page.number + 1}: "{on_top[0]["text"]}" is drawn on top of "{w["text"]}"') continue out.append(w) for a in page.annots(): if a.type[1] in ("Link", "Widget", "Popup"): continue r = a.rect box = box_of(r) under = [w for w in out if overlap_frac(w, box) > 0.3] if under: why.append(f'page {page.number + 1}: a {a.type[1]} annotation covers "{under[0]["text"]}"') out = [w for w in out if w not in under] text = (a.info.get("content") or "").split() if text: step = (r.x1 - r.x0) / len(text) for i, t in enumerate(text): out.append(dict(text=t, x0=r.x0 + i * step, x1=r.x0 + (i + 1) * step, y0=r.y0, y1=r.y1, base=r.y1 - 2, font="annotation", size=0, seq=10**9, hidden=False)) return out, why def check_alignment(pages_words): why = [] money = [w for ws in pages_words for w in ws if not w["hidden"] and MONEY.match(w["text"]) and w["font"] != "annotation"] for c, ws in columns(money).items(): for w in ws: if abs(w["x1"] - c) > 0.6: why.append(f'"{w["text"]}" ends {w["x1"] - c:+.1f} pt from its column edge') for ws in pages_words: for line in lines_of([w for w in ws if not w["hidden"] and w["font"] != "annotation"]): if not DATE.match(line[0]["text"]) and line[0]["text"].lower()[:3] not in MONTHS: continue for w in line: if MONEY.match(w["text"]) and abs(w["base"] - line[0]["base"]) > 0.5: why.append(f'"{w["text"]}" sits {w["base"] - line[0]["base"]:+.1f} pt off its row') return why[:5] + ([f"and {len(why) - 5} more"] if len(why) > 5 else []) def norm(t): return re.sub(r"[^0-9]", "", t) if re.search(r"\d", t) else re.sub(r"[^A-Z]", "", t.upper()) def reread(page, words): """Read each word again on its own, enlarged. All crops go on one sheet: one tesseract call.""" if not words: return [] sheet = pymupdf.open() cols, sw, sh = 3, 220, 34 sp = sheet.new_page(width=cols * sw, height=((len(words) + cols - 1) // cols) * sh + 20) for i, w in enumerate(words): r = pymupdf.Rect(w["x0"] - 2, w["y0"] - 2, w["x1"] + 2, w["y1"] + 2) & page.rect k = min(2.0, (sw - 30) / max(r.width, 1), (sh - 10) / max(r.height, 1)) x, y = (i % cols) * sw + 10, (i // cols) * sh + 10 sp.show_pdf_page(pymupdf.Rect(x, y, x + r.width * k, y + r.height * k), page.parent, page.number, clip=r) out = [[] for _ in words] for o in ocr_words(sp): cx, cy = (o["x0"] + o["x1"]) / 2, (o["y0"] + o["y1"]) / 2 i = int((cy - 10) // sh) * cols + int(cx // sw) if 0 = 2 and not cut) else: ok = all(re.fullmatch(r"[A-Za-z]{3,}", t) for t in readings(best)) and \ distance(norm(w["text"]), norm(shown)) >= 2 if ok: why.append(f'page {pno + 1}: text layer says "{w["text"]}", the image shows "{shown}"') return why def parse_statement(pages_words): """Read summary, opening, transactions, carried and closing balances from word lines. Each number keeps every reading OCR gave it, so one misread digit does not look like an edit.""" st = dict(summary={}, rows=[], opening=None, skipped=0) header_seen = False for pno, ws in enumerate(pages_words): heads = None for line in lines_of(ws): low = " ".join(w["text"] for w in line).lower() names = {} for w in line: t = re.sub(r"[^a-z]", "", w["text"].lower()) for k in ("withdrawal", "deposit", "debit", "credit", "amount", "balance"): if k in t or min(distance(t, k), distance(t, k + "s"))  0.2 * len(tx): return None # too little of the table could be read to judge why, used = [], [] prev = set(st["opening"] or []) for r in st["rows"]: if r["kind"] == "tx": if not r["amount"] or not r["balance"]: prev = set(r["balance"] or []) # unreadable row: restart at the next printed balance continue fits = [(a, b) for p in prev for a in r["amount"] for b in r["balance"] if abs(p + a - b)  0), 2) wd = round(-sum(a for a in used if a = 3 or (page.number == 0 and w["y1"] = 3)] for w, alt in zip(again, reread(page, again)): w["alt"] = alt if words: layered += 1 layer_pages.append((page.number, words, ocr)) seen_pages.append(ocr) continue shown, why = visible_words(page, words) overlap += why text_pages.append(words) seen_pages.append(shown) res["fonts"] = check_fonts(doc, text_pages) if text_pages else None res["overlap"] = overlap if text_pages else None res["alignment"] = check_alignment(text_pages) if text_pages else None if layer_pages: lst = parse_statement([w for _, w, _ in layer_pages]) trusted = None if check_balance(lst) is not None: # the layer's own arithmetic: which cells it vouches for trusted = {id(w) for r in lst["rows"] if r.get("fit") for w in r["words"]} for pno, words, ocr in layer_pages: ocr_why += check_ocr(words, ocr, pno, trusted) res["ocr"] = ocr_why if layered else None res["balance"] = None if (scanned and not use_ocr) else check_balance(parse_statement(seen_pages)) return dict(file=path, pages=doc.page_count, scanned_pages=scanned, revisions=rev["revisions"], producer=meta.get("producer"), checks=res) def main(): ap = argparse.ArgumentParser(description="Check a bank statement PDF for signs of editing.") ap.add_argument("pdf") ap.add_argument("--known", help="JSON file: bank name -> list of Producer strings its statements use") ap.add_argument("--no-ocr", action="store_true", help="skip tesseract (no ocr check, no balances on scans)") ap.add_argument("--json", action="store_true", help="print the full result as JSON") a = ap.parse_args() known = json.load(open(a.known)) if a.known else None r = analyze(a.pdf, known, not a.no_ocr) if a.json: print(json.dumps(r, indent=2)) else: fired = [k for k, v in r["checks"].items() if v] print(f'{a.pdf}: {r["pages"]} page(s), {r["scanned_pages"]} scanned, {r["revisions"]} revision(s), ' f'Producer "{r["producer"]}"') for k, v in r["checks"].items(): if v is None: print(f" n/a {k}") elif v: print(f" FIRED {k}: " + "\n ".join(v[:4])) else: print(f" ok {k}") print(f"{len(fired)} of {len(r['checks'])} checks fired" + (": " + ", ".join(fired) if fired else "")) sys.exit(1 if any(r["checks"].values()) else 0) if __name__ == "__main__": main()
```

## What can this test not tell you?

- How real editors behave. We wrote each edit method ourselves. Real tools differ in whether they write their name, update ModDate, save on top or embed a font again, and that decides what the metadata, revision and font checks see.
- How skilled forgers work. Our edits came from scripts. A person matching noise in a scan or kerning in a font could beat checks that caught our versions.
- How real statements look. Six made-up layouts are far fewer than the formats a lender sees. Real exports can carry several fonts in one column, bold totals or late saves, which would raise false alarms our layouts did not.
- How a different OCR engine would do. Our scans' text layers came from Tesseract, and so did the check's reads. A scanner's own OCR engine would disagree with Tesseract more often.
- Digital signatures and pixel forensics. We did not test either. A valid signature from the bank proves the file unchanged, so check it first where one exists, as our fraud detection guide explains.

## What should a lender do with this?

Run every check, not the one that seems strongest. Fonts, balance, producer and dates each caught edits that no other check caught, and together the eight raised no false alarms on text PDFs in this test. The other four earn their place by pointing at the changed number, such as the value under a box or the old value in an earlier revision.

Send any file that fires to a person along with the reason, and keep the reason in the loan file. A reviewer who sees which number moved can ask the right question.

Then measure the checks on your own traffic before trusting the counts here. Take statements you downloaded from a few banks' websites yourself and count false alarms, especially printed copies and scans. Build the known Producer list from those files. Treat a scan as weaker evidence than a direct download, since a rescan erases most traces.

For the edits nothing caught, ask for evidence from outside the file. That means a statement downloaded during a screen share, a bank data connection, or a check of deposits against [pay stub income](/resources/blogs/pay-stub-income-verification-ocr).

If statements arrive inside one long packet, [split the loan packet](/resources/blogs/split-loan-packet-pdf) first, because these checks expect one statement per file. Our guide to [readable PDFs vs image PDFs](/resources/blogs/readable-pdf-vs-image-pdf) shows how to tell a text page from a scan, which decides which checks can run. The [OCR for lending and underwriting](/resources/blogs/ocr-for-lending-and-underwriting) guide covers what else to read from each loan document.

## Where does DocsAPI fit?

DocsAPI is HyperVerge's document intelligence API for SMB lending and fintech. It classifies each document, extracts fields and tables, and checks extracted data against format rules before it moves on. On its own 2026 benchmark of 1,700 real documents it read multi-page bank statement tables with 91% accuracy, and it processes about 4 million pages a month. That benchmark is separate from the tests here, which used Tesseract and PyMuPDF, so the numbers are not comparable.

The balance check works best on clean extracted tables, and the other seven checks read the PDF file itself, whoever extracts the rows. Pricing starts from $0.02 per page. Access starts with a demo, then a free 30 day trial for qualified lenders, and our [loan verification](/use-cases/loan-verification) page covers the rest of the workflow.

## Frequently Asked Questions

### How can you tell if a bank statement PDF has been edited?

Run several checks, because each sees a different trace: metadata, earlier revisions inside the file, fonts, text hidden under boxes, column alignment, the OCR layer of a scan and the running balance. In our test of 600 edited statements, eight checks together caught 511. The best single content check, fonts, caught 244.

### Is PDF metadata enough to spot a fake bank statement?

No. The Producer and date checks fire only when the editing tool writes its name or a later date. In our test, three of the 12 edit methods kept or restored the bank's own metadata. Two of them were caught only when the math broke, and the third only by fonts or math.

### Does a PDF with two %%EOF markers mean it was edited?

Not by itself. The PDF specification lets any writer append an update, and one of our genuine layouts did that on every file, so counting markers flagged all 40. Comparing the page text, notes and images of the first revision with the final file flagged none of them and caught all 100 edits saved on top.

### Does the running balance check catch edited bank statements?

Only edits that break the math. It caught 229 of 252 edits that raised one deposit and changed nothing else. It caught none of the 255 that also fixed every later balance and total; the 4 flags it raised on those were misread digits on scans.

### Why do scanned bank statements cause false alarms?

Because OCR misreads digits, and a misread digit breaks the balance just like an edit. All 7 false alarms in our test were on scans, after a guard that reads each number twice and treats a break explained by an unsure cell or one wrong digit as a misread.

### What kind of edit gets past every check?

One that keeps the math right and leaves no trace of the tool. Numbers rewritten inside the page's own text commands with the metadata restored, a clone of the bank's template, and a painted scan that was printed and rescanned made up 82 of our 89 misses. Catching those takes evidence from outside the file, such as a bank data connection.


---

**Source URL (cite this):** https://docsapi.co/resources/blogs/detect-edited-bank-statement-pdf
**Author profile:** https://docsapi.co/author/nupura-ughade
**Published by:** DocsAPI (https://docsapi.co)
