Could you please help with one issue?
how font applied to text can be recognized and determined among others?
There are FontEntity and Presentation (*.ppt) (aspose.slides-8.6.0)
We want to see all text of this font. How to do it?
FontEntity fntEnt
int i0 = fntEnt.getFontId();
String name = fntEnt.getFontName();
StringBuilder allText = new StringBuilder();
// Loop through the Array of TextFrames
for (int i = 0; i < textBoxesPPT.length; i++) {
// Loop through paragraphs in current ITextFrame
for (Paragraph para : textBoxesPPT[i].getParagraphs()) {
// Loop through portions in the current IParagraph
for (Portion port : para.getPortions()) {
if (???) {
continue;
}
else {
allText.append(port.getText());
}
}
}
}
I’ve read Manage Fonts - PowerPoint Java API|Aspose.Slides Documentation
but can’t apply it because neither Paragraph nor Portion has not method .getPortionFormat() or getFont(), only getFontIndex
Thank you in advance.
Thank you for your inquiry. Just to let you know our support team have a short break early this week but rest assured your issue will be look into as soon as they return.
Thank you for the details and sorry for the delay in response.
I am afraid, currently, the feature to get the font information of the portion is not available in Aspose.Slides for Java. A feature enhancement request has been registered in our issue tracking system with issue id: SLIDESJAVA-34592.
As per the documentation link mentioned by you, it is for Aspose.Slides for Java v14.x.x and getPortionFormat is available in the latest version. You will need to upgrade to the latest version to use with the above documentation link. However, it doesn’t return the font information and an issue has been registered (as mentioned above).
I have received a feedback from the development team. In most cases a portion doesn’t have its own Font definition. It uses
the font defined in a paragraph or in master styles. The method
Portion.getPortionFormat().getLatinFont() returns the font defined
directly in portion format. For retrieving an inherited font it is
necessary to use Portion.createPortionFormatEffective().getLatinFont().
Please try the following sample code to get the font name from PPTX file.
//Instantiate a Presentation object that represents a PPTX file
Presentation pres = new Presentation(“d:\data\Ppttest.pptx”);
//Accessing a slide using its slide position
ISlide slide = pres.getSlides().get_Item(0);
//Accessing the first and second placeholder in the slide and typecasting it as AutoShape ITextFrame tf1 = ((IAutoShape)slide.getShapes().get_Item(0)).getTextFrame();
//Accessing the first Paragraph IParagraph para1 = tf1.getParagraphs().get_Item(0);
//Accessing the first portion IPortion port1 = para1.getPortions().get_Item(0);
And there are no available interfaces or classes ISlides, ITextFrame… in com.aspose.slides, and “The method createPortionFormatEffective() is undefined for the type Portion”
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.