DEV Community

Clara Sutton
Clara Sutton

Posted on Originally published at plancaliber.hashnode.dev

Rendering Client-Side Watermarked Architectural Proof PNGs with HTML Canvas (Without Exposing Clean Vector Exports)

When building a browser-based floor plan and CAD tool (PlanCaliber), one of the trickiest product-engineering problems is where to draw the boundary between a genuinely useful free preview and a paid vector deliverable.

If you lock the entire export flow behind a hard paywall before a homeowner or contractor can show their draft to a spouse or builder, people abandon the session. On the other hand, if you ship an unwatermarked vector SVG or clean print stylesheet straight to the browser DOM before checkout, anyone can press Ctrl+P or screenshot the modal and walk away with a production sheet.

Here is the exact two-layer architecture we use in TypeScript and HTML5 Canvas to give every free user an instant, crisp 1400×1050 watermarked proof PNG—while keeping clean 1/4"=1'-0" vector PDFs (pdf-lib), 2400px clean PNGs, and layered AutoCAD R12 .DXF files strictly server-gated (HTTP 402).

1. Share One Deterministic Sheet Renderer Between Live Preview and Offscreen Proof Export

Rather than maintaining two separate rendering pipelines (one HTML/SVG DOM preview and one export canvas), we route both the live modal preview and the downloadable free proof through a single pure Canvas renderer renderSheetCanvas(canvas, opts):

renderSheetCanvas(offscreen, {
  cssW: 700,
  cssH: 525,
  dpr: 2,             // exact 1400×1050 physical pixel output
  sheet: targetSheet, // 'A-101' scaled plan or 'M-101' clean white presentation
  zoomMode: 'sheet',
  unlocked: false,    // forces proof watermark pass
  proofExport: true   // appends crisp bottom attribution bar
});
Enter fullscreen mode Exit fullscreen mode

Why does a shared Canvas renderer matter here?

  1. Pixel-exact WYSIWYG: The downloaded proof PNG matches the wall weights, blue dimension strings, room square footage badges, door swings, scale bar, and title block the user just inspected on screen.
  2. DPR-independent resolution: On a 1x office monitor, a screenshot of a 520×390 modal looks muddy. Rendering to an offscreen <canvas> at cssW: 700, cssH: 525, dpr: 2 guarantees every user gets a sharp 1400×1050 bitmap regardless of display scaling.
  3. Zero DOM text/SVG scraping: Because the proof preview is rasterized onto <canvas> with watermarks composited in the same draw pass (and @media print locks unpaid .studio-shell and .modal-backdrop elements), there is no clean vector <svg> sitting in the DOM to extract.

2. Designing Watermarks That Preserve Legibility Without Becoming Hostile

An early mistake we made—and fixed—was placing an opaque vermilion banner directly across the center of the floor plan preview. On a compact residential plan, an opaque center banner obscures kitchen island clearances, hallway doors, and central room labels—making it impossible for the drafter to verify whether their own plan is worth paying for.

Instead, we render two calibrated layers during the Canvas pass when !unlocked:

  1. Low-opacity diagonal grid (0.11 in live modal, 0.16 in downloaded proof PNG): Widely spaced diagonal PLANCALIBER FREE PROOF stamps across the drawing viewport. Every dimension string (36'-0", 28'-0") and room area label (KITCHEN 200 SF) remains effortless to read, while clearly marking the image as an unlicensed working proof.
  2. Dedicated bottom proof strip (proofExport: true): Inside the offscreen export only, we reserve a slim #18191B architectural footer strip separated by a 1.5px vermilion rule (#D94420), printing:
if (proofExport) {
  ctx.fillStyle = '#18191B';
  ctx.fillRect(0, sheetBottom, cssW, proofStripH);
  ctx.fillStyle = '#D94420';
  ctx.fillRect(0, sheetBottom, cssW, 1.5);
  ctx.font = `600 9.5px ${MONO}`;
  ctx.fillStyle = '#FAF9F6';
  ctx.textAlign = 'center';
  ctx.textBaseline = 'middle';
  ctx.fillText(
    'PLANCALIBER FREE PROOF · Clean 1/4"=1\'-0" Vector PDF & 2400px PNG ($9 once) at plancaliber.com',
    cssW / 2,
    sheetBottom + proofStripH / 2 + 0.5,
    cssW - 20
  );
}
Enter fullscreen mode Exit fullscreen mode

That gives the user a genuinely shareable working image they can text to a contractor or family member, while keeping the clean unwatermarked vector PDF (A-101 + M-101), 2400px PNG, vector SVG, and 8-layer AutoCAD R12 .DXF cleanly separated on the paid tier.

3. Clean Blob Download with Safe Filename Slugs & Fallback

Converting the offscreen canvas via toBlob() avoids holding large base64 strings in memory and cleans up the object URL right after the browser initiates the download:

const rawTitle = (solved.doc.title || 'floor-plan').trim().toLowerCase();
const slug =
  rawTitle
    .replace(/[^a-z0-9]+/g, '-')
    .replace(/^-+|-+$/g, '')
    .slice(0, 48) || 'floor-plan';
const filename = `${slug}-plancaliber-proof.png`;

if (typeof offscreen.toBlob === 'function') {
  offscreen.toBlob((blob) => {
    if (blob) {
      const url = URL.createObjectURL(blob);
      const link = document.createElement('a');
      link.href = url;
      link.download = filename;
      document.body.appendChild(link);
      link.click();
      link.remove();
      setTimeout(() => URL.revokeObjectURL(url), 1500);
    }
  }, 'image/png');
}
Enter fullscreen mode Exit fullscreen mode

4. Keep Clean Vector Generation Strictly Server-Side

All unwatermarked exports—5-sheet pdf-lib vector PDFs (A-101, A-102, E-101, A-201, M-101), 2400px clean PNGs, vector SVGs, layered AutoCAD R12 (AC1009) .DXF, 3D .OBJ/.MTL, and Framing/Drywall .CSV takeoffs—are generated and served only after verifying the project's unlock entitlement in Cloudflare D1 (HTTP 402 Payment Required otherwise).

You can test the live 2D/3D studio, inspect a 400% vector detail preview, and download a free watermarked proof PNG directly in your browser (no account required) at PlanCaliber, or check architectural print scale math first with our Floor Plan Scale Calculator.

Note: PlanCaliber is a preliminary space-planning and CAD drafting tool—always field-verify dimensions and confirm local building-department requirements on site.

Top comments (0)