Now Available: Notion-like editor templateNotion-style editor for Tiptap Cloud

cmToPixels utility

The cmToPixels helper lets you easily convert centimeters to pixels, which is useful if you want to define your page or margin sizes in centimeters and need to convert them to pixels for the pageFormat option or custom layouts in the Tiptap Pages extension.

Import

import { cmToPixels } from '@tiptap-pro/extension-pages'

API

cmToPixels(cm: number, dpi?: number): number
  • cm: The value in centimeters to convert.
  • dpi (optional): Dots per inch. If not provided, the utility will auto-detect the DPI of the current environment.
  • Returns: The equivalent value in pixels (rounded).