PrintCalc

Calculate print width & height for Electron webContents.print() and printToPDF()

Key Features

Platform

Electron Windows/macOS/Linux

Dynamic Dimensions

Calculate content width & height

Thermal Printers

58mm, 80mm receipt printers

Unit Conversion

Points, microns, mm, pixels

printToPDF()

Dynamic page size support

webContents.print()

Direct printing with microns

Unit Conversions

Unit Conversion Formula Example (80mm)
Points mm / 25.4 * 72 226.77 points
Microns mm * 1000 80,000 microns
Inches mm / 25.4 3.15 inches
Pixels mm / 25.4 * DPI 639px @ 203 DPI

Quick Start

Measure Content Height

Inject this into webContents to get actual content height for print calculations:

JavaScript
// Measure content height in pixels from webContents
=====================================================

CONTENT HEIGHT MEASUREMENT
--------------------------

// Measure document content height in pixels
const contentHeightPx = await printWindow.webContents.executeJavaScript(`
  Math.max(
    document.body.scrollHeight,
    document.body.offsetHeight,
    document.documentElement.clientHeight,
    document.documentElement.scrollHeight,
    document.documentElement.offsetHeight
  )
`);

Paper Sizes Reference

Paper Type Width (mm) Width (points) Width (microns)
58mm Thermal 58 164.41 58,000
80mm Thermal 80 226.77 80,000
A4 210 595.28 210,000
Letter 216 612.00 216,000

What's Included

Ready to Get Started?

Purchase PrintCalc and calculate perfect print dimensions for your Electron app!

$8.00
Get Started