Dev.to WebDev ๐Ÿ›  Dev ๐Ÿ‘ 0 ๐Ÿ“– 4 min read

Generating True-Scale Architectural Blueprint PDFs (1/4"=1', Arch D 24x36 & Schedules) in Browser TypeScript

Most browser-based floor plan apps take the easy shortcut when you click Export PDF: they rasterize an HTML5 <canvas> at 72 or 150 DPI and drop a PNG inside a Letter page. Print that sheet at a copy shop and pull a tria

Most browser-based floor plan apps take the easy shortcut when you click Export PDF: they rasterize an HTML5 <canvas> at 72 or 150 DPI and drop a PNG inside a Letter page.

Print that sheet at a copy shop and pull a triangular architectural scale ruler across it โ€” nothing measures true. Walls blur when zoomed, doors turn into pixelated arcs, and a 24' kitchen run ends up reading 23'-5" on paper.

When we built TrueDraft CAD โ€” an open-source (GNU AGPL-3.0) 2D/3D architectural floor plan studio that runs entirely in the browser โ€” we wrote a pure-TypeScript vector PDF compiler (src/lib/exporters/pdf.ts) that plots directly in physical paper inches using jsPDF, with true architectural scales (1/4" = 1'-0", 3/16" = 1'-0", 1/8" = 1'-0", 1:50, 1:100), double-line sheet borders, title blocks, and automatic Sheet A2.0 Room/Door/Window schedules.

Here is how the math and layout pipeline works under the hood.

1. Work Internally in SI Meters, Plot Directly in Physical Inches

The single worst bug in web CAD exporters is mixing CSS pixels with paper coordinates. Instead, TrueDraft stores every wall vertex, opening width, and fixture footprint in SI meters (snapping to 1/16" or 10 mm increments in the viewport), then initializes jsPDF with unit: 'in' on standard US architectural sheet sizes:

const SHEET_SPECS: Record<SheetSize, SheetSpec> = {
  letter:  { widthIn: 11, heightIn: 8.5, label: 'Letter',        marginIn: 0.30, titleBlockW: 2.05, fontScale: 1.00 },
  tabloid: { widthIn: 17, heightIn: 11,  label: 'Tabloid 11ร—17', marginIn: 0.40, titleBlockW: 2.55, fontScale: 1.18 },
  arch_d:  { widthIn: 36, heightIn: 24,  label: 'Arch D 24ร—36',  marginIn: 0.55, titleBlockW: 3.80, fontScale: 1.65 }
};

Because jsPDF accepts raw physical inches, converting a model coordinate in meters to a paper offset in inches requires a single exact scalar โ€” inPerMeter:

const SCALE_TABLE: Record<ArchitecturalScale, ScaleDef> = {
  '1/4"=1\'':  { scale: '1/4"=1\'',  inPerMeter: 0.25   / 0.3048, label: '1/4" = 1\'-0"',  family: 'imperial' },
  '3/16"=1\'': { scale: '3/16"=1\'', inPerMeter: 0.1875 / 0.3048, label: '3/16" = 1\'-0"', family: 'imperial' },
  '1/8"=1\'':  { scale: '1/8"=1\'',  inPerMeter: 0.125  / 0.3048, label: '1/8" = 1\'-0"',  family: 'imperial' },
  '1:50':      { scale: '1:50',      inPerMeter: 1000 / 50  / 25.4, label: '1:50',         family: 'metric'   },
  '1:100':     { scale: '1:100',     inPerMeter: 1000 / 100 / 25.4, label: '1:100',        family: 'metric'   }
};

Notice the exact constants (0.3048 m/ft and 25.4 mm/in): a 42'-0" Craftsman cottage (12.8016 m) plotted at 1/4" = 1'-0" measures exactly 10.500" on a Tabloid 11ร—17 sheet โ€” zero DPI rounding drift.

2. Never Silently Clip a Building โ€” Auto-Step Down Standard Scales

A common surprise with fixed-scale printing is when a homeowner drafts a 60' ร— 40' barndominium or a 52' ร— 30' duplex and asks for 1/4" = 1'-0" on an 8.5 ร— 11 Letter sheet (60 ร— 0.25" = 15" โ€” wider than the paper!).

Silently shrinking to an arbitrary scale breaks the printed title block label (SCALE: 1/4"=1'-0" becomes a lie). Clipping walls off the margin ruins the sheet.

Our resolver tries the requested scale first against the available viewport (subtracting outer margins, double border, title block width, and exterior dimension-string padding). If it doesn't fit, it steps cleanly down standard architectural scales in the same unit family โ€” and only falls back to NTS (Auto-fitted) when even 1/8" = 1'-0" or 1:100 exceeds the sheet:

const IMPERIAL_STEPDOWN: ArchitecturalScale[] = ['1/4"=1\'', '3/16"=1\'', '1/8"=1\''];
const METRIC_STEPDOWN: ArchitecturalScale[] = ['1:50', '1:100'];

function resolveSheetScale(
  requested: ArchitecturalScale,
  planW: number,
  planH: number,
  availW: number,
  availH: number,
  sheetLabel: string,
  fitToSheet: boolean
) {
  const maxFitInPerM = Math.min(availW / Math.max(0.5, planW), availH / Math.max(0.5, planH));
  if (fitToSheet) {
    return { inPerMeter: maxFitInPerM, actualScaleLabel: `NTS (Fitted to ${sheetLabel})`, scaleFitted: true };
  }

  const req = SCALE_TABLE[requested] ?? SCALE_TABLE['1/4"=1\''];
  if (planW * req.inPerMeter <= availW + 1e-4 && planH * req.inPerMeter <= availH + 1e-4) {
    return { inPerMeter: req.inPerMeter, actualScaleLabel: req.label, scaleFitted: false };
  }

  const ladder = req.family === 'imperial' ? IMPERIAL_STEPDOWN : METRIC_STEPDOWN;
  for (const candidate of ladder) {
    const def = SCALE_TABLE[candidate];
    if (def.inPerMeter >= req.inPerMeter) continue;
    if (planW * def.inPerMeter <= availW + 1e-4 && planH * def.inPerMeter <= availH + 1e-4) {
      return {
        inPerMeter: def.inPerMeter,
        actualScaleLabel: `${def.label} (Auto-fitted to ${sheetLabel})`,
        scaleFitted: true
      };
    }
  }
  return { inPerMeter: maxFitInPerM, actualScaleLabel: `NTS (Auto-fitted to ${sheetLabel})`, scaleFitted: true };
}

Every time resolveSheetScale steps down, the title block's SCALE field and graphical scale bar update automatically so what is printed in the corner always matches what a ruler measures on paper.

3. Architectural Line-Weight Hierarchy in Inches

Readable CAD blueprints depend on crisp stroke contrast, not color. On every sheet we enforce four distinct pen weights in physical inches (pdf.setLineWidth(...)):

Element Pen Weight (in) Visual Role
Sheet outer border 0.022" Anchors the drawing frame
Cut walls (filled mitered polygons) 0.014" + dark poche Primary architectural figure-ground
Doors, windows, cabinetry & fixtures 0.008" Secondary architectural symbols
Dimension strings, witness lines & 45ยฐ ticks 0.005" Clean technical annotation without clutter

Room polygons are computed from our planar half-edge graph, then subtly tinted 22% toward white (tintTowardWhite(rgb, 0.22)) so printed floor zones stay legible even on black-and-white laser plotters.

4. Multi-Story Packet Assembly (Sheet A1.0, A1.1 & Sheet A2.0 Schedules)

For multi-level buildings (like a two-story house floor plan with Ground + Upper + Basement levels), clicking Export All Floors generates one continuous vector PDF packet:

  1. Sheet A1.0 (Level 1 ยท Ground), Sheet A1.1 (Level 2 ยท Upper), Sheet A1.2 (Level B1 ยท Basement) โ€” each level plotted at consistent architectural scale with synced stair footprints, North arrow, and sheet index (SHEET 1 OF 4).
  2. Sheet A2.0 (Schedules & Material Takeoff) โ€” deterministic multi-column tables listing every room's net square footage & perimeter, complete door/window schedules with rough-opening sizes, drywall sheet counts (4ร—8 sheets with 10% waste factor), framing lumber linear feet, and flooring areas.

Try It Live (Zero Signup) & Read the Source

You can test the full vector PDF compiler right now in your browser โ€” draw walls, load a kitchen remodel or free blueprint template, switch to the Blueprint tab, and download a free Watermarked Proof PDF immediately with no account required:

(Need clean unwatermarked sheets, AIA-layered AutoCAD .DXF, 3D .OBJ, or watertight 3D-print .STL scale models? One-time unlocks start at $9 โ€” zero recurring subscriptions.)

๐Ÿ“ฐ Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.