Hi,
I have a presentation that contains hyperlinked portion on slide #7. I removed hyperlinked portion from paragraph, and created three new portions, each hyperlinked with the external URL that was used in removed portion. When I opened the saved presentation in PowerPoint, newly added portions were not hyperlinked.
Here’s the code I used:
String presentationPath = “www2003.ppt”;
InputStream stream = new FileInputStream(presentationPath);
Presentation presentation = new Presentation(stream);
stream.close();
ISlide slide = presentation.getSlides().get_Item(7);
IAutoShape shape = (IAutoShape) slide.getShapes().get_Item(1);
IParagraph paragraph = shape.getTextFrame().getParagraphs().get_Item(1);
IPortion portion = paragraph.getPortions().get_Item(0);
String externalUrl = portion.getPortionFormat().getHyperlinkClick().getExternalUrl();
int actionType = portion.getPortionFormat().getHyperlinkClick().getActionType();
// Print external URL and action type
System.out.println(externalUrl);
System.out.println(actionType);
// Clear all portions from paragraph
paragraph.getPortions().clear();
// Create new portions
IPortion portion1 = new Portion("
http://24.60.188.10:8080/demos/
");
IPortion portion2 = new Portion("");
IPortion portion3 = new Portion(“GoogleMovies/GoogleMovies.cgi”);
// Add new portions to paragraph
paragraph.getPortions().add(portion1);
paragraph.getPortions().add(portion2);
paragraph.getPortions().add(portion3);
// Set font height just to be visually clear
portion1.getPortionFormat().setFontHeight((float) 18.0);
portion2.getPortionFormat().setFontHeight((float) 18.0);
portion3.getPortionFormat().setFontHeight((float) 18.0);
// Set portions hyperlinks to the one from removed portion
portion1.getPortionFormat().setHyperlinkClick(new Hyperlink(externalUrl));
portion2.getPortionFormat().setHyperlinkClick(new Hyperlink(externalUrl));
portion3.getPortionFormat().setHyperlinkClick(new Hyperlink(externalUrl));
// Print hyperlinks and action types to check if they are set well
System.out.println(portion1.getPortionFormat().getHyperlinkClick().getExternalUrl());
System.out.println(portion1.getPortionFormat().getHyperlinkClick().getActionType());
System.out.println(portion2.getPortionFormat().getHyperlinkClick().getExternalUrl());
System.out.println(portion2.getPortionFormat().getHyperlinkClick().getActionType());
System.out.println(portion3.getPortionFormat().getHyperlinkClick().getExternalUrl());
System.out.println(portion3.getPortionFormat().getHyperlinkClick().getActionType());
presentation.save(“www2003-aspose.ppt”, SaveFormat.Ppt);
Can you check this?
Thanks,
Zeljko