Printing
Printing a Diagram is typically accomplished by making several images of the Diagram and either saving them, inserting them into a PDF or other document, or printing them directly from the browser.
This page uses Diagram.makeSvg, which has its own introduction page: Making Images with GoJS. Depending on your situation, you may want to use raster images to print by calling Diagram.makeImage instead.
Printing to a single page
The following sample demonstrates fitting a diagram of social media connections to the size of one page and printing it by opening the SVG in a separate window:
Printing across multiple pages
In this example, the diagram depicts a very large server infrastructure diagram, and it would be best displayed across several pages. The diagram will be printed in either portrait or landscape depending on whether its width or height is greater.
Our code for print preparation is in a printDiagram function that cuts the Diagram into several images
of a given width and height and renders each such page individually. It also applies some minimal css by adding an
@page rule to the document to make sure the svgs are placed correctly on their own pages.
Those images are in a separate window just to make it easier to manage than combining them with the contents of this page.