It took me so long to figure this out, I thought I would share it.
This prints an MSChart using the metafilepict format after copying the
chart to the clipboard. This provides a high-resolution image rather
than the rough bitmap format.
Note: chtPlot is the name of the MSChart object and "e" is the
PrintPageEventArgs passed by the PrintPage event.
'Print MSChart control in high resolution using metafile
chtPlot.EditCopy() 'save graphic chart to clipboard
'read in metafilepict from clipboard and construct metafile
from this
Dim myStream As IO.MemoryStream =
Clipboard.GetDataObject.GetData(DataFormats.Metafi lePict)
Dim br As New BinaryReader(myStream) 'used to read in values from
memory stream
Dim mapMode As Integer = br.ReadInt32 'not used
Dim xExt As Integer = br.ReadInt32 'not used
Dim yExt As Integer = br.ReadInt32 'not used
Dim hMF As New IntPtr(br.ReadInt32) 'This is what we need
Dim myHeader As New WmfPlaceableFileHeader
Dim myMF As New Metafile(hMF, myHeader)
'define size and position of chart
Dim X, Y, Width, Height As Single
X = 1 'In inches
Y = 1
Width = 5
Height = 4
Dim rect As New Rectangle(X, Y, Width, Height)
e.Graphics.DrawImage(myMF, rect)
'print metafile
e.Graphics.PageUnit = GraphicsUnit.Inch
Hope this helps someone,
Clin