Printing Charts


Q: Coloured Axis Grid lines not printing on HP Lajerset printers.


Original HP printer drivers found in Windows NT 4 have this bug. Try installing a newer version of the HP printer ( www.hp.com ) or setting the grid line Pen style to solid and the Pen color to black.


Q: How can I print a very large line chart in several pages?

First you need to determine how many points you want per page.  Then you can use the Chart1.MaxPointsPerPage property to split the whole chart in several pages. Finally, you can use a loop to print all the pages using the NumPages and Page properties.


Q: How can I print charts to monochrome printers ?

For each different Series type there is a solution. If your printer has good "grey-scale" printing output, you might just need to select good colors for each different level of gray.

The best solution, though, is to select a different Brush.Style for each Series. For example, the Pie Series has a "UsePatterns" property which plots each Pie slice using a different pattern style.

Windows provides only 6 different patterns (vertical, horizontal, diagonal, etc) .

In TeeChart Pro 4.0 and 5.0 you can use the Brush.Bitmap property to fill points using your custom "patterns" in bitmap (picture) format.
Thousands of freeware patterns can be found at many internet web sites (marble, wood, water, iron, etc).


Q: How can I mix TeeChart printed output with other non-TeeChart printed output?

If you require to mix TeeChart printed output with other non-TeeChart printed output then you should use the PrintPartialHandle method to 'attach' the TeeCharts to the existing print jobs e.g.

Private Sub Command2_Click()
Dim HWidth, HHeight, I, Msg1, Msg2 ' Declare variables.
    On Error GoTo ErrorHandler  ' Set up error handler.
    Msg1 = "This is printed on page before Chart"
    Msg2 = "This is printed on page after Chart"
    'Scale & position text.
    HWidth = Printer.TextWidth(Msg) / 2 ' Get half width.
    HHeight = Printer.TextHeight(Msg) / 2   ' Get half height.
    Printer.CurrentX = Printer.ScaleWidth / 3 - HWidth
    Printer.CurrentY = Printer.ScaleHeight / 3 - HHeight

    Printer.Print Msg1 & Printer.Page & "."  ' Print.
    With TChart1.Printer
      .Orientation = poPortrait
      .PrintPartialHandle Printer.hDC, _
            .PageWidth / 3 _
            , (.PageHeight / 3) + 10 _
            , (.PageWidth / 3) * 2 _
            , (2 * (.PageHeight / 3)) - HHeight - 10
    End With
    Printer.CurrentY = 2 * Printer.ScaleHeight / 3 - HHeight
    Printer.CurrentX = Printer.ScaleWidth / 3 - HWidth
    Printer.Print Msg2 & Printer.Page & "."  ' Print.

    Printer.EndDoc  ' Printing is finished.
    Exit Sub
    
ErrorHandler:
    MsgBox "There was a problem printing to your printer."
    Exit Sub
End Sub

Q: What print options does TeeChart Pro Activex Control offer?

  1. PrintChart, Print methods : 1 Chart fills page & form feeds.
  2. PrintPartial (use with BeginDoc, EndDoc) : Will print multiple Charts to a page at defined co-ordinates. You cannot send text to the same page as VB doesn't recognise the DC opened with BeginDoc.
  3. Clipboard : Copy to and paste from to PictureBox.
  4. SaveToFile : Use file as input to PictureBox.
  5. Draw : Draw to PictureBox (Image) : Limitation, no smoothing in font scaling.

    Example of wmf save:
Private Sub Command2_Click()
    Dim HWidth, HHeight, I, Msg ' Declare variables.
    On Error GoTo ErrorHandler  ' Set up error handler.
    Msg = "This text is printed on page after the Chart"
    HWidth = Printer.TextWidth(Msg) / 2 ' Get half width.
    HHeight = Printer.TextHeight(Msg) / 2   ' Get half height.
    TChart1.Export.SaveToMetafile "c:\temp\myChart.wmf"
    Picture1.Picture = LoadPicture("c:\temp\myChart.wmf")
    Printer.PaintPicture Picture1.Picture, 0, 0, Printer.ScaleWidth, 
    Printer.ScaleHeight / 2    Printer.CurrentX = Printer.ScaleWidth / 2 - HWidth
    Printer.CurrentY = Printer.ScaleHeight / 2 - HHeight + 5
    Printer.Print Msg & Printer.Page & "."  ' Print.
    Printer.EndDoc  ' Printing is finished.
    Exit Sub
ErrorHandler:
    MsgBox "There was a problem printing to your printer."
    Exit Sub
End Sub