mxGraph to be previewed.
Optional scale of the output. Default is 1 / mxGraph.pageScale.
mxRectangle that specifies the page format (in pixels).
Border in pixels along each side of every page. Note that the actual print function in the browser will add another border for printing. This should match the page format of the printer. Default uses the mxGraph.pageFormat of the given graph.
Optional left offset of the output. Default is 0.
Optional top offset of the output. Default is 0.
Optional color of the page border. Default is no border. Note that a border is sometimes useful to highlight the printed page border in the print preview of the browser.
Optional string that is used for the window title. Default is 'Printer-friendly version'.
Optional boolean that specifies if the page selector should appear in the window with the print preview. Default is true.
Holds the color value for the page background color.
The border inset around each side of every page in the preview. This is set to 0 if autoOrigin is false.
Holds the color value for the page border.
Specifies is clipping should be used to avoid creating too many cell states in large diagrams. The bounding box of the cells in the original diagram is used if this is enabled.
Reference to the mxGraph that should be previewed.
The margin at the bottom of the page (number).
The margin at the top of the page (number).
Holds the actual number of pages in the preview.
Holds the mxRectangle that defines the page format.
Boolean that specifies if the page selector should be displayed.
Specifies if the background image should be printed.
Specifies if controls (such as folding icons) should be printed. Default is false.
Specifies if overlays should be printed.
Holds the scale of the print preview.
Assign any window here to redirect the rendering in open.
Holds the title of the preview window.
Reference to the preview window.
Holds the horizontal offset of the output.
Holds the vertical offset of the output.
Adds a graph fragment to the given div.
Horizontal translation for the diagram.
Vertical translation for the diagram.
Scale for the diagram.
Number of the page to be rendered.
Div that contains the output.
Contains the clipping rectangle as an mxRectangle.
Adds a page break to the given document.
Adds the given graph to the existing print preview.
Closes the print preview window.
Writes the closing tags for body and page after calling writePostfix.
Creates the page selector table.
Returns the pages to be added after the print output. This returns null.
Returns the pages to be added before the print output. This returns null.
Returns the string that should go before the HTML tag in the print preview page. This implementation returns an X-UA meta tag for IE5 in quirks mode, IE8 in IE8 standards mode and edge in IE9 standards mode.
Returns the link for the given cell state. This returns null.
Returns the root cell for painting the graph.
Returns wnd.
Inserts the background image into the given div.
Shows the print preview window. The window is created here if it does not exist.
Optional CSS string to be used in the head section.
Optional window that should be used for rendering. If this is specified then no HEAD tag, CSS and BODY tag will be written.
Opens the print preview and shows the print dialog.
Parameters:
Optional CSS string to be used in the head section.
Creates a DIV that prints a single page of the given graph using the given scale and returns the DIV that represents the page.
Width of the page in pixels.
Height of the page in pixels.
Optional horizontal page offset in pixels (used internally).
Optional vertical page offset in pixels (used internally).
Callback that adds the HTML content to the inner div of a page. Takes the inner div as the argument.
Integer representing the page number.
Writes the HEAD section into the given document, without the opening and closing HEAD tags.
Called before closing the body of the page. This implementation is empty.
Generated using TypeDoc
Use mxUtils.getScaleForPageCount as follows in order to print the graph across a given number of pages:
Additional pages
To add additional pages before and after the output, getCoverPages and getAppendices can be used, respectively.
CSS
The CSS from the original page is not carried over to the print preview. To add CSS to the page, use the css argument in the open function or override writeHead to add the respective link tags as follows:
Padding
To add a padding to the page in the preview (but not the print output), use the following code:
Headers
Apart from setting the title argument in the mxPrintPreview constructor you can override renderPage as follows to add a header to any page:
The pageNumber argument contains the number of the current page, starting at
Page Format
For landscape printing, use mxConstants.PAGE_FORMAT_A4_LANDSCAPE as the pageFormat in mxUtils.getScaleForPageCount and mxPrintPreview. Keep in mind that one can not set the defaults for the print dialog of the operating system from JavaScript so the user must manually choose a page format that matches this setting.
You can try passing the following CSS directive to open to set the page format in the print dialog to landscape. However, this CSS directive seems to be ignored in most major browsers, including IE.
Note that the print preview behaves differently in IE when used from the filesystem or via HTTP so printing should always be tested via HTTP.
If you are using a DOCTYPE in the source page you can override getDoctype and provide the same DOCTYPE for the print preview if required. Here is an example for IE8 standards mode.