I am trying to read the text in the ppt using the following code.
public class TestPpt {
private static ISlide slide;
private static IShapeCollection shapes;
public static void main(String[] args) {
// Path to the Downloads folder
String downloadsPath = Paths.get(System.getProperty("user.home"), "Downloads", "Test_check.pptx").toString();
// Load the presentation
Presentation presentation = new Presentation(downloadsPath);
try {
// Access the slides in the presentation
slide = presentation.getSlides().get_Item(0);
shapes = slide.getShapes();
for (IShape sh : shapes) {
ITextFrame textFrame = ((IAutoShape) sh).getTextFrame();
if (textFrame != null) {
for (IPortion portion : textFrame.getParagraphs().get_Item(0).getPortions()) {
System.out.println("Text: " + portion.getText());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Output I get is as below
Text: 1
Text:
Text: $
Text: of
Text: 10
Text: Produ… text has been truncated due to evaluation version limitation.
Text:
Text: in
Text: US Ma… text has been truncated due to evaluation version limitation.
Text: durin… text has been truncated due to evaluation version limitation.
Text: 12 4 … text has been truncated due to evaluation version limitation.
Text: Table… text has been truncated due to evaluation version limitation.
Why am I not able to get the entire text properly? Even though I have proper Aspose license with me. Could you please check and update on this?
PPT file for reference →
Test_check.zip (37.1 KB)
Thanks,
Thilak Babu
@Thilakbabu
It seems that you are encountering an issue with reading the complete text from your PowerPoint presentation using Aspose.Slides. The output you are seeing indicates that the text is being truncated due to evaluation version limitations, which typically occurs when the library is not properly licensed.
Here are a few steps you can take to troubleshoot and resolve this issue:
-
Check License Activation: Ensure that your Aspose license is correctly applied in your code. You need to load the license file and set it before performing any operations on the presentation. Here’s how you can do it:
License license = new License();
license.setLicense("path/to/your/Aspose.Slides.lic");
Make sure to replace "path/to/your/Aspose.Slides.lic"
with the actual path to your license file.
-
Verify License Validity: Confirm that your license is valid and not expired. You can check this by contacting Aspose support or checking your purchase details.
-
Test with a Simple Presentation: Create a simple PowerPoint file with known text content and test your code to see if it reads the text correctly. This can help determine if the issue is with the specific presentation you are using.
-
Check for TextFrame Null: Ensure that the shapes you are trying to access actually contain a TextFrame
. You can add a check to skip shapes that do not have a text frame:
for (IShape sh : shapes) {
if (sh instanceof IAutoShape) {
ITextFrame textFrame = ((IAutoShape) sh).getTextFrame();
if (textFrame != null) {
for (IPortion portion : textFrame.getParagraphs().get_Item(0).getPortions()) {
System.out.println("Text: " + portion.getText());
}
}
}
}
-
Review Documentation: If the problem persists, consider reviewing the Aspose.Slides documentation for any additional details on text extraction and licensing.
By following these steps, you should be able to resolve the issue and read the complete text from your PowerPoint presentation. If you continue to experience difficulties, please provide additional details about your license and any error messages you may encounter.
If you need further assistance, feel free to ask!
1 Like