Hello,
When the ‘setFirstSlideNumber
’ API is used on a Presentation prior to converting it to PDF, the hyperlinks in the slides are broken in the resulting PDF.
This behavior can be seen in the latest Aspose Slides for Java version 20.3, the attached "HyperlinksTest.pptx” file and the following Java code:
final String pptxFile = [PATH] + "HyperlinksTest.pptx";
for (boolean setFirstPg : new boolean[] {true, false}) {
Presentation ppt = new Presentation(pptxFile);
String pdfFile = null;
if (setFirstPg) {
// When the first slide number is set, the links are lost in the PDF
ppt.setFirstSlideNumber(3);
pdfFile = pptxFile.replace(".pptx", "_NoLinks.pdf");
} else {
// When setFirstSlideNumber is not set, the links work on the PDF
pdfFile = pptxFile.replace(".pptx", "_LinksWork.pdf");
}
Files.deleteIfExists(Paths.get(pdfFile));
ppt.save(pdfFile, SaveFormat.Pdf);
System.out.println("Saved PDF File: " + pdfFile);
}
If you examine the two generated PDF files:
- HyperlinksTest_LinksWork.pdf: The links in Slides 3 and 4 work in since it was generated without invoking ‘
setFirstSlideNumber
’. - HyperlinksTest_NoLinks.pdf: The links in the do not work in Slides 3 and 4.
Environment Details:
- Aspose Slides for Java 20.3
- Java version 1.8.0_211
- Windows 10 OS (but also reproducible under Linux).
File description in the HyperlinksTest.zip (87.8 KB) attachment:
- HyperlinksTest.pptx: Presentation to be converted to PDF.
- HyperlinksTest_NoLinks.pdf: PDF file generated from the code above on our environment
- HyperlinksTest_LinksWork.pdf: Second PDF file generated from the code above on our environment.
Thank you!