# Title Block Swapper — README

**Version:** v1.18
**Date:** 2026-06-19

---

## What This Is

A single-page web app that takes Cannon Equipment engineering print PDFs and:

1. Replaces the Cannon Equipment logo in the title block with the Amazon logo
2. Replaces "of Cannon Equipment" with "of Amazon" in the copyright notice
   (matching the original font size, color, and position)
3. Generates a **proof sheet PDF** — a tiled grid of every processed page's
   title block, for quick visual QC without opening each file individually

Works on multi-page PDFs and multiple sheet sizes (B-size, A-size, etc.) —
the title block is detected by its position relative to the page edges, so
any standard Cannon Equipment sheet size is handled automatically.

---

## How to Deploy

1. Upload **all three files** to your subdomain's web folder via cPanel
   File Manager:
   - `titleblock_swapper_amazon_v1.18.html` → rename to `index.html`
   - `README_v1.18.md`
   - `CHANGELOG_v1.18.md`
2. Visit the subdomain — it's live, no further setup needed

The page header includes **README** and **Changelog** links (top-right)
that open these files directly — so the docs travel with the deployed app.

To update later, upload the new version's three files (HTML, README,
CHANGELOG) to the same folder, and rename the new HTML to `index.html`,
overwriting the old one. The version number and doc links are shown in the
top-right of the page header, so anyone using it can confirm they're on the
latest version and read what changed.

---

## How to Use

1. Drop PDF files onto the page (or a ZIP file containing PDFs — it will be
   unpacked automatically)
2. Click **Process Prints**
3. A ZIP file downloads automatically containing:
   - Each converted PDF (same filename + `_Amazon` suffix)
   - `PROOF_SHEET_[timestamp].pdf` — tiled title block thumbnails for every
     page, for quick review

No login, no account, no configuration needed. The Amazon logo is built
into the page already.

---

## Security & Privacy

**Nothing leaves the browser.** This app has no backend server. All PDF
processing — reading files, swapping the logo, replacing text, building
the proof sheet — happens entirely in JavaScript running locally in the
user's browser tab. The PDF contents never get uploaded or transmitted
anywhere.

**What does talk to the internet:** Only the JavaScript libraries themselves
(pdf-lib, pdf.js, JSZip, FileSaver), loaded once from cdnjs.cloudflare.com
when the page first loads. These are code files only — drawings never pass
through them.

**Where output goes:** The finished ZIP is generated in-browser and handed
directly to the browser's download mechanism — straight to the user's
Downloads folder, same as any normal file download.

**What persists:** Nothing. Closing or refreshing the page clears
everything — no database, no server-side storage, no logs of what was
processed.

**Access control:** Because this is hosted on a public subdomain, anyone
who knows the URL can use it. If that's a concern, add HTTP authentication
via cPanel's "Password Protect Directories" feature (a server-level
setting, separate from this file).

---

## Technical Notes (for future edits)

Title block coordinates are anchored to the **bottom-right corner** of the
page and expressed as distances from the page edges — this is what makes
the app sheet-size-agnostic:

| Element              | From Right | From Bottom | Size           |
|----------------------|-----------|-------------|----------------|
| Logo                  | 484.6 pt  | 104.8 pt    | 254.7 × 54.5 pt |
| "of [Company]" text   | 771.3 pt  | 103.7 pt (box) / 106.0 pt (baseline) | 122 pt wide, 10.8pt font |
| Proof sheet crop box  | 775 pt    | 165 pt      | (covers full title block) |

**Text color detection:** Some Cannon prints use black text, others blue.
The app renders the page to a hidden canvas and samples the actual pixel
color at the text position, then matches it exactly — no guessing based on
sheet size or page width.

**Text font:** The replacement "of [Customer]" text uses **DejaVu Sans Bold**
(open-licensed, subsetted to printable ASCII and embedded directly in the
HTML file via `fontkit`). This was chosen over the default Helvetica-Bold
because it much more closely matches the weight and letterform proportions
of the original Tahoma Bold used throughout Cannon Equipment prints — the
two are not pixel-identical, but read as the same weight class.

**Cover rectangle padding:** Some Cannon prints use a thin title-block
border (~0.36pt) while others use a thicker one (~1.98pt). The white
rectangle that covers the original text uses minimal left padding (0.5pt)
to avoid visually clipping the thicker border variant, while remaining
wide enough to fully cover the original text underneath.

**Proof sheet rendering:** Each thumbnail is rendered via pdf.js to a canvas,
cropped to the title block region in pixels, then embedded as a PNG image
in the output PDF. (An earlier approach using pdf-lib's `drawPage` could not
be clipped and let drawing content bleed into thumbnails — this was fixed
in v1.11.)

---

## Known Limitations

- Only swaps to **Amazon** — the logo is baked into this file. For other
  customers, a separate version with that customer's logo would be needed.
- Assumes the standard Cannon Equipment title block layout (bottom-right
  anchored). A fundamentally different title block layout would need new
  coordinates calibrated from a sample print.
- Large batches (20+ big multi-page PDFs) may be slow since everything runs
  on the user's own machine — performance depends on their computer.
- **The original Cannon Equipment logo image remains embedded in the output
  PDF file**, hidden underneath a white rectangle and the new logo. It is
  not visible in normal viewing or printing, but someone using PDF editing
  tools (e.g. deleting the top layer in Acrobat, or running image-extraction
  tools) could recover the original Cannon logo image from the file. True
  removal would require rewriting the PDF's internal content streams, which
  was evaluated and found too risky to implement reliably across all print
  layouts (see project history for details). The same applies to the
  original "of Cannon Equipment" text, which is also covered rather than
  removed.
- Some PDF viewers may briefly flash the original Cannon logo on initial
  page load before settling on the final rendered output, due to
  rendering-order behavior in those viewers.

---

## Versioning

Each published update gets a new version number (v1.10 → v1.11 → ...),
shown in the page header. A matching README and CHANGELOG are published
alongside each new HTML file. See `CHANGELOG_v1.18.md` for what changed in
this version.
