How We Built a 100% Browser-Local WhatsApp .zip to Bates-Numbered PDF Engine (Zero Server Uploads)
People preparing evidence for a small claims hearing or a landlord deposit dispute usually end up choosing between two bad options: cropping forty phone screenshots into a messy document, or uploading years of personal f
People preparing evidence for a small claims hearing or a landlord deposit dispute usually end up choosing between two bad options: cropping forty phone screenshots into a messy document, or uploading years of personal family conversations to a remote cloud converter.
When we built ProofExhibit, we set one hard architectural boundary from day one: not a single byte of a user's .zip, _chat.txt, or .csv file may ever cross the network. You should be able to load the page, switch your laptop to airplane mode, drop a 50 MB WhatsApp archive into the browser, and still export a paginated, Bates-stamped PDF.
Here are the four subtle engineering problems we hit doing the entire pipeline in vanilla JavaScriptβand how we solved each one.
1. Invisible Unicode Markers Break Naive WhatsApp Parsers
WhatsApp exports look simple until you parse real files across both iOS and Android devices.
-
iPhone exports wrap timestamps in square brackets (
[12/03/25, 9:41:15 AM] Name: ...) and silently inject invisible Left-to-Right Mark (U+200E) and byte-order mark (U+FEFF) characters right before brackets and around<attached: ...>tags. -
Android exports drop brackets in favor of a dash separator (
11/04/26, 21:18 - Name: ...) and appendIMG-20260814-WA0003.jpg (file attached)at the end of a line. - Multiline messagesβlike pasted lease clauses or address blocksβappear on continuation lines with no timestamp prefix at all.
If you split lines naively and regex-match from column zero, iOS attachment tags silently fail to pair with their JPEGs inside the .zip. Stripping directional marks ([\u200e\u200f\ufeff]) before line classification and normalizing archive paths solved both platforms cleanly.
2. True Non-Recoverable Redaction via Pre-Raster Memory Masking
A classic courtroom horror story involves redacting a Social Security Number or payment card inside a PDF editor by drawing a black rectangle over the text layer. Anyone opening the file can still drag-select and copy the digits sitting underneath.
Instead of overlaying rectangles after the fact, we run regex and custom-term redaction directly on the parsed message strings in browser memory before a single pixel is drawn, replacing matches with [REDACTED] or [REDACTED-CARD], and then rasterizing every sheet onto an HTML5 Canvas prior to assembling the PDF byte stream.
Because the redacted characters never enter the canvas or the output PDF binary, there is zero hidden text layer to scrape.
3. Handling Corrupt Attachments Without Crashing Browser Memory
Real phone backups are messy. Occasionally a WhatsApp .zip contains a truncated or zero-byte .jpg alongside valid photos. Calling createImageBitmap() blindly without isolation will abort the whole render pass.
We wrap each attachment decode inside a per-image try / catch / finally block, explicitly call image?.close() immediately after ctx.drawImage() so GPU texture memory never spikes on multi-hundred-photo archives, render a clean Photo could not be opened placeholder in place, and bubble the exact skipped filenames up to the UI integrity banner so nothing fails silently.
4. Proving Source File Integrity with Web Crypto SHA-256
Judges and opposing counsel routinely ask whether an exported transcript matches the original archive pulled from the phone. Using crypto.subtle.digest('SHA-256', arrayBuffer) on the raw uploaded .zip or .txt bytes takes milliseconds locally and lets us stamp the 64-character digest on Page 1 and every Bates footer (EXHIBIT A Β· PAGE 002 OF 028 Β· SHA-256: 021e810fc0...74c262).
If anyone challenges authenticity later, running shasum -a 256 on the original .zip produces the exact same fingerprint.
If you want to inspect how your own archive parsesβor try the offline airplane-mode test yourselfβthe free 3-page preview and page/size estimator run directly in your browser without signing up.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.
