Hi,
Please provide java docs for following methods:
IComment addComment(java.lang.String text,
ISlide slide,
java.awt.geom.Point2D.Float position,
java.util.Date creationTime)
IComment insertComment(int index,java.lang.String text,ISlide slide,java.awt.geom.Point2D.Float position,
java.util.Date creationTime)
Please explain the method parameters as well.
How do these two methods differ from each other?
What is the purpose of index parameter in insertComment() method?
Which coordinate is considered as origin for slides? We need this information to
understand position parameter.
Can we have slides with different sizes in a presentation?
Thanks
Praneeth
Hi Paraneeth,
I have observed the requirement shared by you and like to share that addComment() adds the comment in end of slide comment collection. Where as the insertComment() adds the comment at desired index in slide comment collection. I suggest you to please try using the following sample code to see the difference.
public static void testComments()
{ String path=“C:\Presentations\”;
Presentation pres = new Presentation();
pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0));
ICommentAuthor author = pres.getCommentAuthors().addAuthor(“Mudassir”, “MF”);
java.awt.geom.Point2D.Float point =new java.awt.geom.Point2D.Float(0.2f,0.2f);
java.awt.geom.Point2D.Float point2 =new java.awt.geom.Point2D.Float(0.4f,0.4f);
java.util.Date date = new java.util.Date();
//Adding slide comment for an author on slide 1
author.getComments().addComment(“Hello Mudassir, this is slide comment”, pres.getSlides().get_Item(0), point, date);
author.getComments().insertComment(0,“Hello Mudassir, this is insert slide comment”, pres.getSlides().get_Item(0), point, date);
//Adding slide comment for an author on slide 1
author.getComments().addComment(“Hello Mudassir, this is second slide comment”, pres.getSlides().get_Item(1), point, date);
ISlide slide = pres.getSlides().get_Item(0);
//if null is passed as an argument then it will bring comments from all authors on selected slide
IComment[] Comments = slide.getSlideComments(author);
//Accessin the comment at index 0 for slide 1
String str = Comments[0].getText();
pres.save(path+“Comments.pptx”, SaveFormat.Pptx);
//Select comments collection of Author at index 0
ICommentCollection commentCollection = Comments[0].getAuthor().getComments();
System.out.println(commentCollection.get_Item(0).getText());
Many Thanks,
Hi Mudassir,
Thanks for the quick reply.
How can we validate the position parameter?
addComment method did not add any comment to second slide when we provided following values to the position parameter.
java.awt.geom.Point2D.Float point = new java.awt.geom.Point2D.Float(1.2f, 0.0f);
But it works for other values like (0.0f, 0.0f) and (0.2f,0.2f).
We need to determine the possible valid values for position parameter.
Please help us in resolving this.
Thanks,
Praneeth
Hi Praneeth,
I have observed your requirement. It seems to be an issue with Aspose.Slides while setting the position. The position can be from 0,0 to SlideSize.getX(), SlideSize().getY(). I have created an issue with ID SLIDESJAVA-34760 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.
We are sorry for your inconvenience,
Hi,
Our requirement is to add a native comment on presentation at a given position.
We followed your reply to calculate position parameter.
The code works for some coordinates but not for all.
Please let me know if there is something wrong in the code given below.
Does it calculate position correctly?
What coordinates should we use for adding comments at all four corners (top left, top right, bottom left, bottom right) and center of a presentation slide?
The sample presentation is attached with this post.
public class NativeComment{
Presentation ppt;
NativeComment(String fileName){
ppt=new Presentation(“RP_Overview.pptx”);
}
ISlide getSlideByID(long slideId) {
ISlide slide = null;
if (ppt != null) {
for (ISlide s : ppt.getSlides()) {
if (s.getSlideId() == slideId) {
slide = s;
break;
}
}
}
return slide;
}
public Presentation getPresentation() {
return ppt;
}
public IComment addComment(String authorName, String authorInitials, String commentText, long slideId, Float position, Date creationTime)
{
ISlide slide = getSlideByID(slideId);
//Adding Author
ICommentAuthor author = ppt.getCommentAuthors().addAuthor(authorName, authorInitials);
IComment comment = author.getComments().addComment(commentText, slide, position, creationTime);
ppt.save(“RP_Overview_Native_Comment.pptx”, SaveFormat.Pptx);
return comment;
}
public static void main(){
NativeComment nativeComment= new NativeComment(“RP_Overview.pptx”);
Presentation ppt= nativeComment.getPresentation();
Dimension2D size = ppt.getSlideSize().getSize();
float x = (float)size.getWidth();
//float x=0.0f;
float y=0.0f;
// float y = (float)size.getHeight();
long slideId = ppt.getSlides().get_Item(2).getSlideId();
String commentText = “FPRCS_CommentID_1”;
Float point = new Float(x, y);
java.util.Date date = new java.util.Date();
String authorName = “Manisha”;
String authorInitials = “MS”;
nativeComment.addComment(authorName, authorInitials, commentText, slideId, point, date);
}
}
Thanks,
Praneeth
Hi Praneeth,
I like to share that the issue SLIDESJAVA-34760 has been created for the purpose the comment position is not working correctly. The positions 0,0 to maximum slide size is the one that Aspose.Slides should be accepting. This is issue and we will share the feedback with you as soon as the issue will be resolved.
We are sorry for your inconvenience,
Hi,
I manually added a comment at the bottom right corner of a slide and then accessed the same comment using Aspose.Slide. Using that comment, I got the values of its X and Y coordinates and then I used those same coordinates to add a comment at bottom right corner using Aspose.Slides addComment() method. This added the comment correctly at the expected position.
Does it mean Presentation.getSlideSize() method not return correct size?
Thanks,
Praneeth
Hi Praneeth,
I have further tested the comments on my end and have observed that following are the values of X,Y when comment is at top left and bottom right corner. Please mind it that It
should be aligned to Slide size values and accept position on slide as
other normal shapes does. This is why I have added a ticket so that its mapping can set in accordance with slide size. By using the below information, you can devise the approximate position on your end to serve the purpose.
Top left Approximate
X: 0.0 Y: -5.511810886673629E-4
Bottom Right Approximate
X: 0.45393699407577515 Y: 0.34031495451927185
As shared earlier, we will share the solution with you once the issue will be resolved.
Many Thanks,
The issues you have found earlier (filed as SLIDESJAVA-34760) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.