Jump to content
Software FX Community



Recommended Posts

The ChartFX Printer Class provides important and very helpful properties to print the chart. Using the supported members, you will have control over the margins, paper orientation, color or pattern printing, among others. The supported methods will also allow you to prompt the user with page setup, preview, and print dialogs to ensure the user prints exactly what they want; however, this is more of an extended functionality of the PrintDocument Class provided by the .NET Framework. When you print, you still have to create a PrintDocument Object which is handled by the BeginPrint, PrintPage, and EndPrint Events respectively. If you want to manipulate how a page is printed, you will need to do this in the PrintPage Event. Again, this is beyond the scope of ChartFX; however, I will post some code that can help you accomplish what you need. The code snippet is below:

private void Form1_Load(object sender, EventArgs e)


printCover = true; // Global flag to control how to print the pages

PrintDocument pd = new PrintDocument();pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);



void pd_PrintPage(object sender, PrintPageEventArgs e)


if (printCover)


e.Graphics.DrawString("This is my cover sheet", new Font("Arial", 14, FontStyle.Bold), Brushes.Black, 25, 25, StringFormat.GenericTypographic);

printCover =


e.HasMorePages =

true; // Forces an additional page to be printed






chart1.Paint(e.Graphics, new Rectangle(25, 25, e.MarginBounds.Width, e.MarginBounds.Height / 2), PaintStyles.Print);



The main part of the code is the PrintPage Event which determines how my document is going to be printed. I am using a flag that helps print a first page before printing the chart image. The HasMorePages property, tells the Event Handler that there are more pages to be printed; in this case, we need to print the chart. Hope this helps with what you need.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...