Get the Number of PDF Pages for Each Presentation Slide with Speaker Notes in Java

I used Java Aspose Slide version 22.6 to convert PPTX file to PDF file. There are some slides in my PPTX file containing speaker notes, and some of speaker notes can be multiple pages long. I need some Aspose APIs that can identify which slides on the PDF file have speaker notes and how many pages the speaker notes have and slide page numbers. Please advice. Thanks!

@bing.liu,
Thank you for posting your requirements.

Please share a sample PowerPoint presentation, output PDF file and describe your expected information that you want to get for the document. Then we will do our best to help you.

SamplePPTwithSpeakerNote.zip (82.6 KB)
I have to zip my sample test file to conform the upload file format. This test PPT file is pretty simple, some of slides ( e.g. the Slid1 and Slide 4) have a long speaker notes which can take up to two slides. I used the following Aspose classes to convert PPT to PDF file. Then I read the PDF file with com.aspose.pdf.Document pdfDocument to find the total pages and each page in the PDF file.

com.aspose.pdf.Document pdfDocument = new Document(inPPTFilePath);
for (int i = 1; i <= pdfDocument.getPages().size(); i++) {
    // Get the current page
    Page pdfPage = pdfDocument.getPages().get_Item(i);
    // Extract the page number
    int pageNumber = pdfPage.getNumber();
}

My question is how to get the Total Page count of each slide which has the Speaker Note and its page number?

public void convertPPTtoPDFimage(String inPPTFilePath, String outFilePath){
    com.aspose.slides.Presentation presentation = new com.aspose.slides.Presentation(inFilePath);

    com.aspose.slides.PdfOptions pdfOptions = new com.aspose.slides.PdfOptions();
    pdfOptions.setShowHiddenSlides(true);
    com.aspose.slides.INotesCommentsLayoutingOptions notesAndCommentsOptions = pdfOptions.getNotesCommentsLayouting();
    notesAndCommentsOptions.setNotesPosition(NotesPositions.BottomFull);
    notesAndCommentsOptions.setCommentsAreaColor(Color.WHITE);
    presentation.save(outFilePath, com.aspose.slides.SaveFormat.Pdf, pdfOptions);
    presentation.dispose();
    ImageMain.localFileList.add(outFilePath);
}

PPTtoPDFconversionWithLongSpeakerNotes.zip (167.1 KB)

I also uploaded the PDF file converted from PPT. You could tell the Slide 1 has two slides because it has a longer speaker notes, the same for Slide 4.
Of the five slides in this presentation, “Slide 1” is identified as page 2, which has two pages long. The same for Slide 4 is identified as page 5, which has two pages long.

@bing.liu,
Thank you for the details. If I understand correctly, you would like to know the number of pages for each slide, including speaker notes, and its page number before the conversion to PDF is done. Could you please confirm?

thanks getting back to me.
I would like to know the number of pages for each slide, including speaker notes, and its page number AFTER the conversion to PDF is done .

If this can not be done, it would be helpful to get before the conversion to PDF is done . Any suggestion?

@bing.liu,
Thank you for the explanation. I will get back to you ASAP.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESJAVA-39108

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@bing.liu,
Please try using the following code snippet to get information about the number of output pages for presentation slides containing Slide Notes:

Presentation pres = new Presentation("in.pptx");
try {
    // Get the slide number of the presentation
    int slidesNumber = pres.getSlides().size();
    System.out.println("Number of slides = " + slidesNumber);

    // Get the slide number including notes pages
    IRenderingOptions options = new RenderingOptions();
    options.getNotesCommentsLayouting().setNotesPosition(NotesPositions.BottomFull);
    BufferedImage[] bmps = pres.getThumbnails(options);
    System.out.println("Number of slides with notes = " + bmps.length);

    // Get the number of additional notes pages for a slide (slide #2 in this example)
    bmps = pres.getThumbnails(options, new int[] {2});
    System.out.println("Additional Notes Slides for Slide #2 = " + (bmps.length - 1));
} finally {
    if (pres != null) pres.dispose();
}