Free Support Forum - aspose.com

Missing image after pdf convert

Dear all, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

If I add an image to a chart (at runtime) and then convert the resulting file into a pdf file, the image is missing. How can I bypass this behavior? I add the image to the chart by the following lines of code:

FileStream stream = new FileStream(Path.Combine(System.Windows.Forms.Application.StartupPath,"images\\logochart.bmp"), FileMode.Open, FileAccess.Read);

Picture pic0 = chart.Shapes.AddPictureInChart(250, 300, stream, 100, 100);

Regards

Erik

Hi Erik,

Thank you for considering Aspose.

We have found your mentioned issue after an initial test. We will look into it and get back to you soon. You issue has been registered in our issue tracking system with issue id CELLSNET-12203.

Thank You & Best Regards,

Hi,

Thank you for considering Aspose.

Please try the attached latest version of Aspose.Cells for .NET. We have fixed your mentioned issue.

Thank You & Best Regards,

Hi, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

it works basically. But there seems to be a little problem with the positioning of the images left. Please take a look at the attached file. There you can see the location of the label in the generated excel file compared to the image location in the generated pdf file.

Thanks and best regards

Erik

Hi,

Could you post your generated xls and pdf files here to show the issue, we will check it soon.

Thank you.

Hi, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

sorry. I forgot to attach the file showing the differences. I will also create an excel / pdf example and provide it to you soon.

Erik

Hi,

OK, We will be waiting your xls/pdf example with files.

Thank you.

Hi,

please find attached the promised example files (code + initial xls file + chart as well as the generated results)

Thanks in advance

Regards

Erik

Hi,

Thanks for sharing the sample files with code.

Yes, we found that the location of the image in the chart is not the same in the generated pdf file. We will figure it out soon.
The issue has been logged into our issue tracking system with an issue id: CELLSNET-12336.

Thank you.

Hi,

Thank you for considering Aspose.

Please call Chart.Calculate(); before saving the file. Please see following code:


Workbook wb = new Workbook();

wb.Open(@"F:\FileTemp\files\ColumnChartDemo.xls");

Worksheet wsChart = wb.Worksheets[0];

//Erzeugen des Diagramms und setzen der wesentlichen Eigenschaften

int chartIndex = wsChart.Charts.Add(ChartType.Column, 1, 1, 25, 10);

Chart chart = wsChart.Charts[chartIndex];

//Hauptgridzeielen einblenden

chart.MajorGridLines.IsVisible = true;

//Grundfarbe weiß

chart.PlotArea.Area.ForegroundColor = System.Drawing.Color.White;

//Kein umschließender Rahmen

chart.ChartArea.Border.IsVisible = false;

//Festlegung der Datenquelle

chart.NSeries.Add("'Data'!B2:B11", true);

chart.NSeries.Add("'Data'!B2:B11", true);

chart.NSeries.Add("'Data'!C2:C11", true);

chart.NSeries.Add("'Data'!C2:C11", true);

chart.NSeries.CategoryData = "'Data'!A2:A11";

chart.NSeries.SecondCatergoryData = "'Data'!A2:A11";

chart.NSeries[0].Name = "Master1";

chart.NSeries[1].Name = "Master2";

chart.NSeries[1].Line.IsVisible = false;

chart.NSeries[1].Area.Formatting = FormattingType.None;

chart.NSeries[2].Name = "Detail1";

chart.NSeries[2].PlotOnSecondAxis = true;

chart.NSeries[2].Line.IsVisible = false;

chart.NSeries[2].Area.Formatting = FormattingType.None;

chart.NSeries[3].Name = "Detail2";

chart.NSeries[3].PlotOnSecondAxis = true;

chart.SecondValueAxis.IsVisible = true;

chart.SecondValueAxis.Crosses = CrossType.Automatic;

//Legende Ausblenden

chart.IsLegendShown = false;

//Platzierung auf der Folie vornehmen

chart.ChartObject.HeightCM = 14;

chart.ChartObject.WidthCM = 25;

chart.ChartObject.UpperLeftColumn = 2;

chart.ChartObject.UpperLeftRow = 7;

chart.Placement = PlacementType.FreeFloating;

FileStream stream = new FileStream(@"F:\FileTemp\files\logochart.bmp", FileMode.Open, FileAccess.Read);

Picture pic0 = chart.Shapes.AddPictureInChart(375, 250, stream, 90, 90);

chart.Calculate();

wb.Save(@"F:\FileTemp\files\reportColumnAspose.pdf", FileFormatType.Pdf);

wb.Save(@"F:\FileTemp\files\reportColumnAspose.xls");

Thank You & Best Regards,

Hi, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

If I call chart.Calculate() before I save the workbook the position of the inserted image is in excel the same as in the pdf file.

Just one more question regarding the AddPictureInChart(int top, int left, …) method. I tried to rearrange the position of the image in the chart. If I change the first parameter called top, the images moves left or right. If I change the second one - called left - the images moves up or down. Is there something mixed up?

Regards

Erik

Hi,

Thank you for considering Aspose.

We have found your mentioned issue after an initial test. We will look into it and get back to you soon. Your issue has been registered in our issue tracking system with issue id CELLSNET-12442.

Thank You & Best Regards,

Hi,

Please try the attached version. We have fixed the issue.

Thank you.

Hi, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Now the parameter seems to work as expected. But there is a new problem with the positioning of the label in pdf. Please take a look at the attached files. You can find there the program, the initial excel file, the used logo as well as both (pdf and xls) generated files. It is clearly evident that there is a difference between xls and pdf.

Related to this topic I got to other points of interest.

- It is possible to change the z-Order of the inserted logo? It should overlay the grid lines but it should not be overlay any kind of graph, shown in the chart.

- It is possible to place the logo with offset x and y values that refers e.g. to the top left corner of the major grid lines. If I use the existing positioning approach the final position of the logo depends on the chart data. So it could happen, that there are often different logo positions throughout a long presentation.

Thanks in advance and best regards

Erik

Hi,

We will soon provide a property to get the position of left-top of the plot area without tick labels.


Thank you.

Hi,

Please try the attached fix with following sample code:

Workbook wb = new Workbook();
wb.Open(@“F:\FileTemp\files\reportSource.xls”);
Worksheet wsChart = wb.Worksheets[0];
Worksheet wsData = wb.Worksheets[1];

//Erzeugen des Diagramms und setzen der wesentlichen Eigenschaften
int chartIndex = wsChart.Charts.Add(ChartType.ColumnStacked, 1, 1, 25, 10);
Chart chart = wsChart.Charts[chartIndex];
//Hauptgridzeielen einblenden
chart.MajorGridLines.IsVisible = true;
//Grundfarbe weiß
chart.PlotArea.Area.ForegroundColor = System.Drawing.Color.White;
//Kein umschließender Rahmen
chart.ChartArea.Border.IsVisible = false;

//Festlegung der Datenquelle
chart.NSeries.Add("’" + wsData.Name + “’!B2:F6”, true);
chart.NSeries.CategoryData = “’” + wsData.Name + “’!A2:A6”;


//Anpassen der Farben der einzelnen Datenreihen
chart.NSeries[0].Area.ForegroundColor = System.Drawing.Color.AliceBlue;
chart.NSeries[1].Area.ForegroundColor = System.Drawing.Color.Beige;
chart.NSeries[2].Area.ForegroundColor = System.Drawing.Color.CadetBlue;
chart.NSeries[3].Area.ForegroundColor = System.Drawing.Color.DarkBlue;
chart.NSeries[4].Area.ForegroundColor = System.Drawing.Color.Firebrick;

//Legende Ausblenden
chart.IsLegendShown = false;

//Platzierung auf der Folie vornehmen
chart.ChartObject.HeightCM = 11;
chart.ChartObject.WidthCM = 25;
chart.ChartObject.UpperLeftColumn = 2;
chart.ChartObject.UpperLeftRow = 12;
chart.Placement = PlacementType.FreeFloating;
chart.Calculate();


//Wasserzeichen / Quelllabel einstellen
FileStream stream = new FileStream(@“F:\FileTemp\files\logochart.bmp”, FileMode.Open, FileAccess.Read);
Aspose.CellsPicture pic0 = chart.Shapes.AddPictureInChart(
chart.PlotAreaWithoutTickLabels.Y, chart.PlotAreaWithoutTickLabels.X, stream, 90, 90);

wb.Worksheets[1].IsVisible = false;
wb.Save(@“F:\FileTemp\reportAspose.xls”);
wb.Save(@“F:\FileTemp\reportAspose.pdf”, FileFormatType.Pdf);



Thank you.

Hi, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

the provided version doesn’t fix the problem completely. The image alignment fits only the top Gridline but it doesn’t fit the value axis. The picture is placed some centimeter to the right of the value axis.

Do you also consider the mentioned z-Order problem?

Erik

Hi Erik,

a)The picture is placed some
centimeter to the right of the value axis.<o:p></o:p>
Could you create your desired chart in MS Excel and post it here? We will check it soon.
b) z-Order problem
The z-order should be same as the order of inserting shapes. If the grid lines are a part of the chart and not a shape in the chart's shapes, we can change the display order of the chart's object. We just work as MS Excel.


Thank you.

Hi, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please find attached a sample excel file that shows the desired logo position. I would like to use a small offset to place the logo to the top left corner of the plot area (independent of the plot area size).

Today I realized that my understanding of the z-Order arrangement of objects depends on the used excel version. I always tried to insert the logo as an image an place it in the chart. But the source file that I use as a template for our new report system created with excel 2007. There the logo is inserted as a background image and then shrunk to the needed size (this option seems to be not available in excel 2003).

By the way, I believe that I can solve this problem with a small workaround. I know that there is free place on the top left or right of the diagram. So I can decide the correct label position in my chart. It is possible to determine the top right corner of the plot area, too?

Regards

Erik

Hi Erik,

Thanks for providing us the template file.

We will look into it and get back to you soon.

Thank you.