Documentation

Page layout

Pagination & legal numbering

Two plugins for document-shaped work — contracts, specifications, reports, policies. A live paginated page view that shows real page boundaries, headers, footers and page numbers, and multi-level legal numbering (1, 1.1, 1.1.1) for clause-numbered documents. Both ship in the standard license.

Paginated page view

Page view renders the editable as a paper column at true page width and draws a boundary, page number, and optional header/footer for every page — the print-layout view a word processor gives you. It is purely presentational: nothing it draws is written into your content, and the HTML you save is byte-for-byte identical whether page view is on or off.

Load the plugin after the editor, then toggle it from your own UI:

<script src="richtexteditor/rte.js"></script>
<script src="richtexteditor/plugins/pagination.js"></script>

<script>
  var editor = new RichTextEditor("#editor");

  editor.setPageView(true);       // turn page view on
  editor.togglePageView();        // flip it
  editor.isPageView();            // -> true | false
  editor.getPageCount();          // -> number of pages
  editor.getPageGeometry();       // -> { pageWidth, pageHeight, margins..., contentHeight }
</script>

Pages break on block boundaries, so a paragraph, table row or image is never split down the middle. A forced break — what the insertpagebreak toolbar command inserts — always starts a new page, exactly as it does on export.

Page setup

Geometry comes from the document’s own page setup when your app supplies one, so what you see on screen matches what the PDF and Word exports produce. You can also set it at runtime:

editor.setPageSetup({
  format: "Letter",          // A4 | Letter | Legal | A3 | A5 | Tabloid
  orientation: "portrait",   // portrait | landscape
  margins: { top: 1, right: 1, bottom: 1, left: 1 }   // inches, or "25mm" / "2cm" / "72pt" / "96px"
});
Config optionDefaultPurpose
paginationEnabledfalseStart with page view on.
pageFormat"A4"Paper size when the document carries no page setup.
pageOrientation"portrait"Portrait or landscape.
pageMargins1in all roundMargins, in inches or any CSS length.
paginationShowPageNumberstrueDraw the per-page number badge.
paginationShowPageCounttruePage 3 of 12 vs Page 3.

Headers & footers

Header and footer HTML repeat on every page and support {page} and {total} placeholders:

editor.setPageSetup({
  headerHtml: "Master Services Agreement &mdash; Acme Corp",
  footerHtml: "Page {page} of {total} &middot; Confidential"
});