Page Settings
4 Apr 202213 minutes to read
Page settings can customize the appearance, width, and height of the diagram page.
Page size and appearance
-
The size and appearance of the diagram pages can be customized with the page settings property.
-
The
width
andheight
properties of page settings define the size of the page and based on the size, theorientation
will be set for the page. In addition to that, the appearance of the page can be customized withsource
and set of appearance specific properties. -
The
color
property is used to customize the background color and border color of the page. -
The
margin
property is used to define the page margin. -
To explore those properties, refer to
Page Settings
.
<ejs-diagram id="container" width="100%" height="700px" nodes="@ViewBag.nodes">
<e-diagram-pagesettings width="300" height="300" orientation="LandScape" showPageBreaks="true"></e-diagram-pagesettings>
</ejs-diagram>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Syncfusion.EJ2.Diagrams;
using System.Drawing;
namespace EJ2MVCSampleBrowser.Controllers.Diagram {
public partial class DiagramController: Controller {
// GET: Nodes
public ActionResult Nodes() {
List < DiagramNode > nodes = new List < DiagramNode > ();
nodes.Add(new Node() {
Id = "node1",
Width = 100,
Height = 100,
Style = new NodeStyleNodes() {
Fill = "#6BA5D7",
StrokeColor = "White"
},
text = "node1",
OffsetX = 100,
OffsetY = 100,
});
ViewBag.nodes = nodes;
return View();
}
}
public class Node: DiagramNode {
public string text;
}
}
Set background image
Stretch and align the background image anywhere over the diagram area. The source
property of background
allows to set the path of the image. The scale
and the align
properties help to stretch/align the background images.
<ejs-diagram id="container" width="100%" height="700px" nodes="@ViewBag.nodes">
<e-diagram-pagesettings>
<e-pagesettings-background source="https://www.w3schools.com/images/w3schools_green.jpg" align="XMinYMid" scale="Meet"></e-pagesettings-background>
<e-pagesettings-margin left="10" right="10" bottom="10" top="10"></e-pagesettings-margin>
</e-diagram-pagesettings>
</ejs-diagram>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Syncfusion.EJ2.Diagrams;
using System.Drawing;
namespace EJ2MVCSampleBrowser.Controllers.Diagram {
public partial class DiagramController: Controller {
// GET: Nodes
public ActionResult Nodes() {
List < DiagramNode > nodes = new List < DiagramNode > ();
nodes.Add(new Node() {
Id = "node1",
Width = 100,
Height = 100,
Style = new NodeStyleNodes() {
Fill = "#6BA5D7",
StrokeColor = "White"
},
text = "node1",
OffsetX = 100,
OffsetY = 100,
});
ViewBag.nodes = nodes;
return View();
}
}
public class Node: DiagramNode {
public string text;
}
}
Multiple page and page breaks
When multiple page is enabled, the size of the page dynamically increases or decreases in multiples of page width and height and completely fits diagram within the page boundaries. Page breaks is used as a visual guide to see how pages are split into multiple pages.
The multiplePage
and showPageBreak
properties of page settings allows you to enable/disable multiple pages and page breaks respectively.
<ejs-diagram id="container" width="100%" height="700px" nodes="@ViewBag.nodes">
<e-diagram-pagesettings>
<e-pagesettings-background source="https://www.w3schools.com/images/w3schools_green.jpg" align="XMinYMid" scale="Meet"></e-pagesettings-background>
<e-pagesettings-margin left="10" right="10" bottom="10" top="10"></e-pagesettings-margin>
</e-diagram-pagesettings>
</ejs-diagram>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Syncfusion.EJ2.Diagrams;
using System.Drawing;
namespace EJ2MVCSampleBrowser.Controllers.Diagram {
public partial class DiagramController: Controller {
// GET: Nodes
public ActionResult Nodes() {
List < DiagramNode > nodes = new List < DiagramNode > ();
nodes.Add(new Node() {
Id = "node1",
Width = 100,
Height = 100,
Style = new NodeStyleNodes() {
Fill = "#6BA5D7",
StrokeColor = "White"
},
text = "node1",
OffsetX = 100,
OffsetY = 100,
});
ViewBag.nodes = nodes;
return View();
}
}
public class Node: DiagramNode {
public string text;
}
}
Boundary constraints
The diagram provides support to restrict/customize the interactive region, out of which the elements cannot be dragged, resized, or rotated. The boundaryConstraints
property of page settings allows you to customize the interactive region. To explore the boundary constraints, refer to Boundary Constraints
.
<ejs-diagram id="container" width="100%" height="700px" nodes="@ViewBag.nodes">
<e-diagram-pagesettings boundaryConstraints="Page" width="300" height="300" orientation="LandScape" showPageBreaks="true"></e-diagram-pagesettings>
</ejs-diagram>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Syncfusion.EJ2.Diagrams;
using System.Drawing;
namespace EJ2MVCSampleBrowser.Controllers.Diagram {
public partial class DiagramController: Controller {
// GET: Nodes
public ActionResult Nodes() {
List < DiagramNode > nodes = new List < DiagramNode > ();
nodes.Add(new Node() {
Id = "node1",
Width = 100,
Height = 100,
Style = new NodeStyleNodes() {
Fill = "#6BA5D7",
StrokeColor = "White"
},
text = "node1",
OffsetX = 100,
OffsetY = 100,
});
ViewBag.nodes = nodes;
return View();
}
}
public class Node: DiagramNode {
public string text;
}
}