We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Chart to PDF issues...

Hi Syncfusion,

I am in the process of evaluating your products as replacement for an existing components.
I am interested in creating charts from data stored on disk and importing them into a PDF file as vector images.

As the attached project will show (using random data to represent reading data from disk) I am doing this by saving my chart as an EMF file, then importing this file into a PDF document then finally saving the PDF.
I do however have a number of issue with doing this:

1.At 1601 points although the EMF file is correct, the series lines aren't imported into the PDF file. The chart is there... it just has no data.

2. Up until the point where the PDF file is saved, I cannot delete the EMF file since it is in use... this means I have to create 100 EMF files all with different file names before I can delete them again after the PDF save.

3. I cannot find a way to get the data from the chart into PDF without saving an EMF file to disk. Is there a way?

3. The process of creating a PDF file with 100 charts takes over 500Mb of RAM, is there a method for progressive file saving and releasing of RAM so as not to completely kill the processing PC? There might be circumstances where instead of 1601 points I have 16001 points and during testing my 4Gb of RAM development machine runs out!

4. When creating 100 different charts I receive this warning message:
C# effected Line: pdfDoc.Pages[i].Graphics.DrawImage(PdfImage.FromFile(file), 0, 0, 400 , 600);

Message:
ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x35bac0 to COM context 0x35bc30 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.

Any assistance you can offer for these issues would be greatly appreciated and help me in my evaluation of Syncfusion's products.

Thank you
Craig.



Chart2PDF_d5f6d4c4.zip

4 Replies

BP Bhuvaneswari P Syncfusion Team January 22, 2009 01:23 PM UTC

Hi Craig

Thank you for evaluating syncfusion products.

1. This issue is known issue when emf generated using chart control and we have already notified our developer regarding this and we will improve this in our future release.

2.I cannot delete the EMF file since it is in use.
I am able to reproduce the issue in your code. Please dispose the image once the inserted into the PDF document by using the below code snippet:

metafile = new PdfMetafile(file);
g.DrawImage(map, new Rectangle(0, 0, 400, 600));
metafile.Dispose();


3. I cannot find a way to get the data from the chart into PDF without saving an EMF file to disk. Is there a way?

This is the only way to insert the chart into the PDF document, since there is no option in chart to save the image as stream. But we can use either vector or scalar image. If we use scalar image (png or jpg) the image size will be reduced and performance also increased.

4. When creating 100 different charts I receive this warning message:
C# effected Line: pdfDoc.Pages[i].Graphics.DrawImage(PdfImage.FromFile(file), 0, 0, 400 , 600);

I am able to reproduce the issue. Since we are creating image each time and inserting into the PDF, so by default the memory size is increasing. Please save the image in the same file name instead creating new image in each time. We can use png type image instead of EMF image to increase performance and optimize the memory size, but quality will be differing when using the scalar images. Please use the below code snippet to do so:


for (int i = 0; i < 100; i++)
{
chartControl1.Title.Text = "Chart2PDF #" + i.ToString();
file = fileName + "\\Chart2PDF" + ".png";
PdfBitmap map = new PdfBitmap(Image.FromFile(file));
page = section.Pages.Add();
g = page.Graphics;
g.DrawImage(map, new Rectangle(0, 0, 400, 600));
map.Dispose();
}


5. The process of creating a PDF file with 100 charts takes over 500Mb of RAM:
As said in the question number 4. This is due to saving the image each time and also there is issue with our PDF also while inserting EMF image it taking some memory, we have notified our developer regarding this issue. Please use the scalar image as we suggested in the question 4.

Please let me know if you have any other questions.

Best Regards,
Bhuvana




CE Craig Ewens January 22, 2009 03:17 PM UTC

Hi Bhuvana
Firstly, thank you for your responses... although informative they’ve not really enabled my evaluation of Syncfusion to proceed since the key functions chart & pdf are supposed to perform don’t work.

1. Do we have a date for this? I am informed by a Mr Brandon White that the chart control is going to have a performance enhancement release in Feb 09. Is this EMF issue also going to be fixed in this release? or is it just on a list of issues to fix? According to your web site of “Open Issues” the EMF to PDF bug was fixed in version 6.2.0.13 but I am using version 7.10.21 and experiencing this still.

2. This solved the 100 EMF files, thank you.

3. Is adding the save as image stream going to be implemented at some point for chart? (have you got a date?). It does seem like an obvious addition since PdfImage.FromStream(...) exists... perhaps PdfImage.FromChart(...) would be an even better solution?

4. PNG images do not give the desired clarity resolution for the charts I am required to make. I appreciate they increase performance but if the image quality is bad it’s no good to us. It has to be vector images I’m afraid. If the C# line I quoted cannot be altered to stop the warning from Microsoft occurring; perhaps you can suggest an alternative method... maybe creating more than one PDF file and then merging them? Is there an efficient manner in which this can be accomplished?

5. As stated above I need vector images to be used within the PDF file.


To restate my goals for evaluation... I need to create (at least) 100 vector charts with (at least) 1601 points of data in each and produce a PDF file of them all in the most efficient manner. This means not using 1Gb of RAM, not generating 100's of files which I then need to delete and not crashing or taking 10 minutes to complete... I’m hoping Syncfusion has the products to accomplish this as I like using them, but these really are the minimum standards I require at the moment.

Kind Regards
Craig



BP Bhuvaneswari P Syncfusion Team January 23, 2009 12:22 PM UTC

Hi Craig,

Thanks for the details.

Regarding the EMF issue while converting Chart to EMF, option for saving the image as stream and for performance improvement?

For these issues I have notified our development and after analysis this we will get back to you a two days time frame.

According to your web site of “Open Issues” the EMF to PDF bug was fixed in version 6.2.0.13 but I am using version 7.10.21 and experiencing this still.
We have fixed for some of the EMF issues (some specific files) reported early and not for this issue reported in this forum thread.

For further questions please create a Direct-Trac incident with the below details as subject, so that we can track the issues efficiently:

Subject: 79107 -Chart to PDF issues...

Best Regards,
Bhuvana




CE Craig Ewens January 23, 2009 12:52 PM UTC

Thank you Bhuvana,

I have now created a Direct-Trac incident as requested.


Loader.
Live Chat Icon For mobile
Up arrow icon