I am writing to you about a problem we encountered in working with PowerPoint document using the Aspose Slides for Java library (v23.02). Specifically, when we load the PP document and attempt to extract a list of notes for the slides, getting NullPointerException when a note contains a hyperlink.
This issue is reproducible on both Linux 7.4 and Windows 10 platform with java full version “1.8.0_351-b10”.
I am attaching the source Presentation file as well as the stack tracepptxAndStackTrace.7z (46.9 KB)
.
The sample code demonstrating the issue is below.
Thank you.
final IPresentation sourcePpt = new Presentation("Safe Harbor Statement.pptx");
final int SLIDES_COUNT = 1;
try {
List<String> notesFromSlides = getNotesFromAllSlides(sourcePpt, SLIDES_COUNT);
for (int i=0; i< notesFromSlides.size(); i++) {
System.out.println(notesFromSlides.get(i));
}
} catch (Exception ex) {
System.err.println("exception getting notes from all slides");
ex.printStackTrace();
}
/**
* helper method to get a list of slide notes for all the slides.
*/
public static List<String> getNotesFromAllSlides(IPresentation presentation, int slideCount) {
List<String> notesList = new ArrayList<String>();
for (int i = 0; i < slideCount; i++) {
String notes = null;
INotesSlide noteSlide = presentation.getSlides().get_Item(i).getNotesSlideManager().getNotesSlide();
if (noteSlide != null) {
ITextFrame tf = noteSlide.getNotesTextFrame();
if(tf!=null && tf.getParagraphs()!=null) {
// Initializing conversion options
TextToHtmlConversionOptions options = new TextToHtmlConversionOptions();
options.setTextInheritanceLimit(TextInheritanceLimit.TextBox); //Inherit only from TextFrame's style.
options.setEncodingName("UTF16");
notes = tf.getParagraphs().exportToHtml(0, tf.getParagraphs().getCount(), options);
}
}
notesList.add(notes);
}
return Collections.unmodifiableList(notesList);
}