We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

AutoShapes - Callouts

Is there any way to add an autoshape(callout) in the latest release? I just need to add a simple "callout" in a specific location.

Thanks!

I need to create callouts, too. Perhaps now this thread will be revived.

Hello Dears,

You can add the callout shapes in your presentations just like other autoshapes using both Aspose.Slides for Java and Aspose.Slides for .NET for PPTX. Please use the Java code snippet given below to add the callout shape in your presentation. Please proceed to this link to see the list of possible autoshapes that can created using Aspose.Slides for Java. Please proceed to this link to see the list of possible autoshapes that are supported with Aspose.Slide for .NET. This link may help you in knowing, how to add autoshapes using Aspose.Slides for .NET.

PresentationEx pres = new PresentationEx();
SlideEx sld=pres.getSlides().get(0);
int idx = sld.getShapes().addAutoShape(ShapeTypeEx.CALLOUT1 , 50, 150, 300, 0);

Thanks and Regards,

Mudassir,

Thanks for the reply. Once I have the callout, how do I set where it points to? It will be superimposed on a table and I’ve been able to set the X coordinate close enough, but the Y value is way off.

Thanks,

Ken

Dear Ken,

I am afraid, I have not been completely able to understand the issue specified by you. Can you please share the code snippet and the explain the problem to some more extent as well.

Thanks and Regards,

Here is some of my code:

int idx = slide.getShapes().addAutoShape(ShapeTypeEx.CALLOUT_WEDGE_ROUND_RECTANGLE, 150, 150, 50, 50);
AutoShapeEx pptxAutoShape = (AutoShapeEx) slide.getShapes().get(idx);

The callout has a point at the bottom and I want to place it on cell (1,8). This code works well for the horizontal position, although I add 75% of the width so that the callout is centered in the cell.


CellEx c2 = table.get(1, 8);


pptxAutoShape.setX((float)(c2.getFirstColumnIndex() * c2.getWidth() + c2.getWidth() * .75f));

I use a similar formula for the vertical position:

pptxAutoShape.setY((float)(c2.getFirstRowIndex() * c2.getHeight()));

This doesn’t work. The callout appears closer to (1,6) than it does to (1,8). Part of the problem is that I don’t know how the height and width of the cells translate into pixels, and whether I need to take into account the table’s position on the slide.

I should mention that the formulas only work for single cells. No idea how I center the callout over a merged cell.

I hope this will clear things up.

Dear Ken,

I have worked with the code snippet shared by you and I feel it may not work well in all situations since all rows may not have same heights and all column may not have same width. I have developed some new logic for this and please use the code snippet given below to accomplish your task. Please feel free to share if the problem still persists.

int idx = slide.getShapes().addAutoShape (ShapeTypeEx.CALLOUT_WEDGE_ROUND_RECTANGLE, 150, 150, 50, 50);
AutoShapeEx pptxAutoShape = (AutoShapeEx) slide.getShapes().get(idx);

int iDesiredCol,iDesiredRow,iColWidth=0,iRowHeight=0;
iDesiredCol=2;
iDesiredRow=3;

iColWidth=(int)table.getX();
iRowHeight+=(int)table.getY();

CellEx c2 = table.get(iDesiredCol, iDesiredRow);

for(int iCol=0;iCol<=iDesiredCol;iCol++)
iColWidth+=table.get(iCol,0).getWidth();

for(int iRow=0;iRow<iDesiredRow;iRow++)
iRowHeight+=table.get(0,iRow).getHeight();

iRowHeight-=pptxAutoShape.getHeight();

pptxAutoShape.setX((float)iColWidth );

pptxAutoShape.setY((float)iRowHeight );

Thanks and Regards,

Mudassir,



Thanks for the reply. We’re close; unfortunately, your code does not take into account the presence of merged cells.



I’ve attached some files showing the various attempts. “Desired” is of
course what I want: the callout is centered over the merged cells.
“Result1” is what I get when I use your code as-is; removing
iRowHeight-=pptxAutoShape.getHeight() produces “desired”.



In the case of “original,” there are merged cells in row 0 and your code
doesn’t correct for their increased width. That is, cells (0,0) through
(4,0) report a width of 82, cells (5,0) through (7,0) report a width of
49.2, and cell (8,0) reports a width of 16.4. The callout thus appears
too far to the right.

Dear Ken,

I have modified the code snippet to meet your need of merged cells. Hopefully, it will serve the purpose. I have used the OffsetX and OffesetY properties of cell that return the width and height distance from top left corner of table.

String path="D:\\Aspose Data\\Ken\\";
//Instantiate PresentationEx class that represents PPTX file
PresentationEx pres = new PresentationEx(path+"original.pptx");
//Access first slide
SlideEx slide = pres.getSlides().get(0);
//Initialize null TableEx
TableEx table = null;
ShapeEx shp;
//Iterate through the shapes and set a reference to the table found

for (int i=0;i<slide.getShapes().size();i++)
{
shp=slide.getShapes ().get (i);
if (shp instanceof TableEx)
table = (TableEx)shp;
}
int idx = slide.getShapes().addAutoShape(ShapeTypeEx.CALLOUT_WEDGE_ROUND_RECTANGLE, 150, 150, 50, 50);

AutoShapeEx pptxAutoShape = (AutoShapeEx) slide.getShapes().get(idx);

int iDesiredCol,iDesiredRow,iColWidth=0,iRowHeight=0;
iDesiredCol=20;
iDesiredRow=8;
CellEx c2 = table.get(iDesiredCol, iDesiredRow);

iColWidth=(int)table.getX()+(int)c2.getOffsetX();
iRowHeight+=(int)table.getY()+(int)c2.getOffsetY();

pptxAutoShape.setX((float)iColWidth );

pptxAutoShape.setY((float)iRowHeight );

//Write PPTX to Disk
pres.write(path+"tableJ.pptx");

Thanks and Regards,

Much better, thanks!

Is there a workaround for PPT? The Cell API doesn’t include getOffsetX().

Dear Ken,

I regret to inform you that similar properties like getOffsetX() in case of PPT is unavailable. You may try using work around shared in previous post. Unfortunately, there is no property available in case of PPT table cell to identify whether the given cell is valid or not. So in my humble opinion, I don't feel any work around available to achieve the goal as in case of PPTX table.

We are sorry for your inconvenience,

I suspected as much. It may come down to simply hiding cell borders to simulate merging.

Thanks,

Ken

Dear Ken,

I feel this is one possible work around that can be adopted to simulate the effect of cell merging on visual basis only.

Thanks and Regards,