Hello,
I'm beggining with Infragistics tools and I'm building an app with some statistic charts. At this point, I'm trying to add a button that allows me to export my XamDataChart to an Excel File.
Thank you for any help or idea.
I am just checking if you require any further assistance on the matter.
Hello Slaimi,
I have been looking into latest post and it is occurs because the provided approach uses the actual size(height,width) of the XamDataChart. In this scenario the width of the PDF page is not big enough to show the whole chart. If you would like to export the entire chart to the pdf page you can check the actual width of the XamDataChart in the ‘SaveImage’ method like :
if (element != null)
{
RenderTargetBitmap bmpSource;
if (element.ActualHeight < 800)
bmpSource =
new RenderTargetBitmap(
(int)element.ActualWidth,
(int)element.ActualHeight, 96, 96,
PixelFormats.Pbgra32);
}
else
(int)element.ActualHeight, 60, 60,
bmpSource.Render(element);
imgEncoder.Frames.Add(BitmapFrame.Create(bmpSource));
using (Stream stream = File.Create(fileName))
imgEncoder.Save(stream);
stream.Close();
I am attaching a modified version of Chris’ sample application(ExportXDChartToPDF119194_Modified.zip).
Please note that this is a custom approach.
Let me know, if you need any further assistance on this matter.
Hi Chris,
I still have the same problem with this approach: when my chart is on full screen, the PDF file contains only a part of the chart and not the entire chart. You can try with your example and modify the width and the height.
I would like to thank you for your precious help.
Scincerely.
Hi Slaimi,I took a look at the blog post that you mentioned and the approach that Tom describes is exactly what I had in mind.I have included a modified version of that sample which demonstrates this behavior; to use the approach you would need to also install NetAdvantage for Windows Forms which includes the Documents assemblies that are required; for my sample, I have included only the assemblies necessary that you may not have on your machine.Please take a look at the attached sample and if you have any further questions regarding this behavior, please let me know.Sincerely,Chris KDeveloper Support EngineerInfragistics, Inc.www.infragistics.com/support
Hi,
Well here's what my code looks like
Report report = new Report(); EmbeddedVisualReportSection section1 = new EmbeddedVisualReportSection(this.Linechart); report.Sections.Add(section1);
// here I add the xamdatachart to a section (this.Linechart) and add the section to a Report object (I'm using Infragistics.Windows.Reporting)
string PDFPrinterName = "Bullzip PDF Printer"; string sLocalAppData = Solution.GetEnv("LOCALAPPDATA"); if (sLocalAppData == "") { sLocalAppData = Solution.GetEnv("USERPROFILE") + @"\Local Settings\Application Data"; } string PrinterSettingFileName = sLocalAppData + @"\PDF Writer\" + PDFPrinterName + @"\runonce.ini";
System.Text.Encoding iso8859 = System.Text.Encoding.GetEncoding("ISO-8859-1"); FileStream fs = new FileStream(PrinterSettingFileName, FileMode.Create, FileAccess.Write); StreamWriter sr = new StreamWriter(fs, iso8859);
string TempFilename = System.IO.Path.GetTempFileName(); string OutputFilename = TempFilename + ".pdf"; string StatusFilename = TempFilename + ".log"; sr.WriteLine("[PDF Printer]"); sr.WriteLine("Output = " + OutputFilename); sr.WriteLine("RememberLastFileName = no"); sr.WriteLine("RememberLastFolderName = no"); sr.WriteLine("ShowSaveAs = never"); sr.WriteLine("ConfirmOverwrite = no"); sr.WriteLine("ShowSettings = never"); sr.WriteLine("ShowPDF = no"); sr.WriteLine("ShowProgress = no"); sr.WriteLine("ShowProgressFinished = no"); sr.WriteLine("SuppressErrors = yes"); sr.WriteLine("Author = " + m_Solution.ReadResourceFromXaml(this, "msg_PDFAuthor")); sr.WriteLine("Format = pdfa1b"); sr.WriteLine("StatusFile = " + StatusFilename); sr.Close(); fs.Close(); report.ReportSettings.PrintQueue = new PrintQueue(new PrintServer(), PDFPrinterName); report.Print(false, false);
// as u can see, here I'm creating a filsestream to add all the informations and I'm using the BullZip PDF Printer to export the file
Process epg = new Process(); epg.StartInfo.UseShellExecute = true; epg.StartInfo.FileName = System.IO.Path.GetFileName(OutputFilename); epg.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(OutputFilename); epg.StartInfo.Arguments = ""; epg.StartInfo.Verb = "open"; epg.Start();
//last step is to lanch the process with the file created
the problem here is that I'm having only a part of the chart as shown in the images
and here's another approach that I have found but couldn't use http://es.infragistics.com/community/blogs/tom_puglisi/archive/2012/01/16/wpf-data-chart-to-pdf.aspx
please take the time to look at them and thanks for the help.
Sincerely