How to: Create a Non-Printable Brick
- 3 minutes to read
This example creates a brick that is visible on the screen but is not printed.
All bricks created by the XtraPrinting Library can be printed. Sometimes you need to create bricks used for navigation purposes only. Although these bricks are displayed on screen, they should be excluded from the printout. Use the Brick.CanPublishToFormats property to accomplish this task.
The following image shows the resulting report preview:
using DevExpress.XtraPrinting;
// ...
BrickGraphics graph = printingSystem1.Graph;
// Start the report generation.
printingSystem1.Begin();
// Set the modifier to specify the page area.
graph.Modifier = BrickModifier.MarginalHeader;
string format = "Page {0} of {1}";
graph.Font = graph.DefaultFont;
graph.BackColor = Color.Transparent;
RectangleF r = new RectangleF(0, 0, 0, graph.Font.Height);
// Create a brick.
PageInfoBrick brick = graph.DrawPageInfo(PageInfo.NumberOfTotal, format,
Color.Black, r, BorderSide.None);
brick.Alignment = BrickAlignment.Far;
brick.AutoWidth = true;
// Create another brick with different alignment.
brick = graph.DrawPageInfo(PageInfo.DateTime, "{0:MMMM dd}", Color.Black, r,
BorderSide.None);
// Set the modifier to specify the page area.
printingSystem1.Graph.Modifier = BrickModifier.DetailHeader;
graph.BackColor = Color.Silver;
// Create a brick that is hidden on the printout.
TextBrick tBrick = new TextBrick(BorderSide.None, 1, Color.Black, Color.Khaki,
Color.Blue);
tBrick.Url = "https://www.devexpress.com/";
tBrick.Text = "Click here to visit our web site";
tBrick.CanPublishToFormats = CanPublishToFormats.None;
printingSystem1.Graph.DrawBrick(tBrick, new RectangleF(0, 0, 200, 20));
// Create a brick that serves as a column header.
printingSystem1.Graph.DrawString("Report Items", Color.Black,
new RectangleF(0, 20, 200, 20), BorderSide.All);
// Set the modifier to specify the page area.
printingSystem1.Graph.Modifier = BrickModifier.Detail;
graph.BackColor = Color.White;
// Create bricks.
for (int i = 0; i < 100; i++)
printingSystem1.Graph.DrawString("Item N" + Convert.ToString(i + 1),
Color.Black, new RectangleF(0, 20 * i, 200, 20), BorderSide.All);
// Finish the report generation.
printingSystem1.End();
// Preview the report.
printingSystem1.PreviewFormEx.Show();
See Also