Authors:Jared Jurkiewicz
Project owner:Jared Jurkiewicz

Have you ever wanted to pull your hair out when printing an HTML document because it would page break at bad locations? There is actually a little-known CSS style that allows you to set a point at which printing should page break the document, the ‘page-break-after: always’ style. This feature can be important when editing documents on the web, so it’s very useful in some cases to be able to insert a page break on demand. This plugin provides such a function to the dijit.Editor.


Once required in and enabled, this plugin provides the following features to dijit.Editor.

  • Button with icon in toolbar for inserting a page break at the current location in the document.
  • Keyboard hotkey: CTRL-SHIFT-ENTER for inserting a page break at the current location in the editor. (Note that this is a similar keybind to those used by commercial word processors, so it will hopefully be familiar and easy to pick up.).
  • Dynamic styling in the page to make the document appear broken into two pages at that point. Also provides @media CSS so that the styling is not printed (via a print plugin), only that the document page breaks when encountered.


Basic Usage

Usage of this plugin is quite simple and painless.

First include the CSS for it:

@import "dojox/editor/plugins/resources/css/PageBreak.css";

Then require it into the page where you’re using the editor:


Once it has been required in, all you have to do is include it in the list of extraPlugins (or the plugins property if you’re reorganizing the toolbar) for you want to load into the editor. For example:

<div data-dojo-type="dijit/Editor" id="editor" data-dojo-props="extraPlugins:['pageBreak']"></div>

And that’s it. The editor instance you can reference by ‘dijit.byId(“editor”)’ is now enabled with the PageBreak plugin! You can use the button or hotkey to insert page breaks as you desire.


The page break plugin only has one limitation coded into it, it will not allow page breaks to be inserted in block elements like <ul> and <ol>, because it tends to make the page view look a bit odd.


Basic Usage

@import "{{baseUrl}}dojox/editor/plugins/resources/css/PageBreak.css";
<b>Enter some text or select a position, then push the PageBreak button or use CTRL-SHIFT-ENTER, to insert a page break at the desired point.</b>
<div data-dojo-type="dijit/Editor" height="250px" id="input" data-dojo-props="extraPlugins:['pagebreak']">
blah blah & blah!
<td style="border-style:solid; border-width: 2px; border-color: gray;">One cell</td>
<td style="border-style:solid; border-width: 2px; border-color: gray;">
Two cell
<li>item one</li>
item two
Error in the documentation? Can’t find what you are looking for? Let us know!