Skip to main content

How to: Create a Non-Printable Brick

  • 3 minutes to read

This topic illustrates how to create a brick that is visible on the screen, but not printed.

All bricks created by the XtraPrinting Library can be printed. Occasionally you have to create bricks used for navigation purposes only. Although these bricks are displayed on screen, they should be excluded from the printout. This can be easily accomplished via the BrickBase.CanPublish property.

Note

The BrickBase.CanPublish property has no effect on export to different formats.

The following code sample illustrates the implementation of a non-printable brick. The preview of the resulting report is shown in the picture.

NonPrintableBrick

using DevExpress.XtraPrinting;
// ...

BrickGraphics graph = printingSystem1.Graph;

// Start the report generation.
printingSystem1.Begin();

// Set the modifier - 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);

// Change the page area - set the modifier.
printingSystem1.Graph.Modifier = BrickModifier.DetailHeader;

graph.BackColor = Color.Silver;

// Create a brick, which will be hidden in 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.Printed = false;
printingSystem1.Graph.DrawBrick(tBrick, new RectangleF(0, 0, 200, 20));

// Create a brick - a column header.
printingSystem1.Graph.DrawString("Report Items", Color.Black, 
    new RectangleF(0, 20, 200, 20), BorderSide.All);

// Change the page area - set the modifier.
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();

Now we have a non-printable brick which is used for navigation, and is not printed out.

Tip

A complete sample project is available in the DevExpress Code Examples database at https://supportcenter.devexpress.com/ticket/details/e6/xtraprinting-library-how-to-create-a-non-printable-brick.

See Also