Comments

Hi,


Attached Comment.ppt file have a comment. Can you help me please, do you have support for comments and how I can get text from it?

Thanks,
Bojan

Hi Bojan,


Thanks for inquiring Aspose.Slides.

I like to share that you can access the slide comment from any given presentation. Please use the methods shared in sample codes below for adding and extracting the slide comments from presentation.

public static void AddPPTSlideComments() throws Exception
{
String path = “C:\Users\Mudassir\Downloads\”;

Presentation pres = new Presentation();

//Getting first slide
Slide slide = pres.getSlides().get(0);
//Adding Autthor
CommentAuthor author = pres.getCommentAuthors().addAuthor(“Mudassir”);


//Position of comments
java.awt.Point point = new java.awt.Point(100,100);

java.util.Date date = new java.util.Date();
//Adding Slide comments
slide.getSlideComments().addComment(author, “MF”, “Hello Mudassir, this is slide comment”, date, point);

//Adding Empty slide
slide = pres.addEmptySlide();

//Position of comments
java.awt.Point point2 = new java.awt.Point(500,1400);
//Adding Slide comments
slide.getSlideComments().addComment(author,“MF”,“Hello Mudassir, this is second slide comment”, date,point2);

Comments comments = slide.getSlideComments();
//Accessin the comment at index 0 for slide 1
String str = comments.get(0).getText();

pres.write(path + “Comments.ppt”);

}

public static void IdentifyPptComments() throws Exception
{
String path = “C:\Users\Mudassir\Downloads\”;

Presentation pres = new Presentation(path + “Comments.ppt”);

java.text.DateFormat dateFormat = new java.text.SimpleDateFormat(“yyyy/MM/dd HH:mm:ss”);

int i = 1;
for (Slide slide : pres.getSlides())
{
Comments comments=slide.getSlideComments();
for (int j=0;j<comments.size();j++ )
{
Comment comment = comments.get(j);
System.out.println(“Slide :” + Integer.toString(i)+ " has comment: " + comment.getText() + " with Author: " + comment.getAuthor().getName() + " posted on time :" + dateFormat.format(comment.getCreatedTime()) + “\n”);
i++;
}
}

}

Many Thanks,