My program needs to be able to export the reports it creates into PDF files. I can make the PDF file just fine, but in order to add the Chart I need to save the Chart as an image, preferably PNG.
Now comes the trouble spot, the chart needs to be resized inside the export function in order for it to fit smoothly on the page. How can I do this without displaying the chart to the user?
I'm having difficulty explaining this so perhaps an example will help
public void ToPFD(string FileName, Chart zChart){
// PDF functions up above// Set the width and height of the chartzChart.Width = zChart.Height = Math.Min(pdfPage.Width - 30, pdfPage.Height - tblEnd - 60);
/* I have tried calling Refresh(), all the Invalidate*() functions, * and anything else that seemed likely to work here. None of them * did. I believe because there Asynchronous.. I was trying to * put to sleep this thread and then interrupt it when the refresh * was done but I couldn't figure out what event was called when * the refresh was finished. */
// Export the chartzChart.Export(tmpFile);
}
Thanks for taking a look. Hope to resolve this problem soon as I see no work around.