Hi,
I’m adding a specific zero-width space character (\u200B) portion before and after each existing portion in the presentation. For some presentations, it works as expected (the added portion is not visible). But for some other, this portion gets underlined. Please see the attached screenshot underline.jpg (703.7 KB) and the source presentation file 1.ppt.zip (909.7 KB)
Here’s the code I use:
private static final String ZERO_WIDTH_SPACE_CHARACTER = "\u200B";
private static final String URL = "http://example.com/";
public static void main(String[] args) {
String filePath = args[0];
String targetPath = args[1];
Presentation presentation = new Presentation(filePath);
ISlideCollection slides = presentation.getSlides();
for (ISlide slide : slides) {
IShapeCollection shapes = slide.getShapes();
for (IShape shape : shapes) {
if (shape instanceof IAutoShape) {
IAutoShape autoShape = (IAutoShape) shape;
IParagraphCollection paragraphs = autoShape.getTextFrame().getParagraphs();
for (IParagraph paragraph : paragraphs) {
IPortionCollection portions = paragraph.getPortions();
List<IPortion> temporaryPortions = new ArrayList<>();
for (IPortion portion : portions) {
temporaryPortions.add(createHyperlinkPortion());
temporaryPortions.add(portion);
temporaryPortions.add(createHyperlinkPortion());
}
portions.clear();
for (IPortion portion : temporaryPortions) {
portions.add(portion);
}
}
}
}
}
presentation.save(targetPath, SaveFormat.Html);
presentation.dispose();
}
private static IPortion createHyperlinkPortion() {
IPortion portion = new Portion(ZERO_WIDTH_SPACE_CHARACTER);
portion.getPortionFormat().setHyperlinkClick(new Hyperlink(URL));
return portion;
}
Can you check this?
I’m using Aspose.Slides for Java 17.10.
Thanks,
Zeljko