Hi
In Aspose Slides for Java, we are using the following code snippet for inserting the footer text
java.awt.Color footerColor = java.awt.Color.RED;
// Set the text color for the footer.
IFillFormat fillFormat = paragraph.getParagraphFormat().getDefaultPortionFormat().getFillFormat();
fillFormat.setFillType(FillType.Solid);
fillFormat.getSolidFillColor().setColor(footerColor);
// Lock the footer shape.
footerShape.getAutoShapeLock().setSelectLocked(true);
footerShape.getAutoShapeLock().setSizeLocked(true);
footerShape.getAutoShapeLock().setTextLocked(true);
footerShape.getAutoShapeLock().setPositionLocked(true);
footerShape.getAutoShapeLock().setGroupingLocked(true);
We are using the licensed version of Aspose. The footer text is showing in grey colour.
As you can see in the snippt,we are already setting the colour of the footer text to red in the code. The footer text is still not showing in red colour, can you help?
Thanks
@Rama_Menon
Cause
The issue of footer text appearing in grey instead of the specified red color could be due to several reasons, including the default style settings of the footer or potential overrides from the master slide.
Solution
To ensure that the footer text displays in the desired color, you can try the following steps:
-
Check Master Slide Settings: Ensure that the master slide does not have any conflicting styles that might override the color settings you are applying.
-
Set Color After Locking: If you are locking the footer shape, make sure to set the color after locking it. Sometimes, locking the shape can prevent subsequent style changes from being applied.
-
Use the Correct Fill Format: Ensure that you are correctly applying the fill format to the specific portion of the text that you want to change.
Code
Here’s an updated code snippet that sets the footer text color after locking the shape:
java.awt.Color footerColor = java.awt.Color.RED;
// Lock the footer shape.
footerShape.getAutoShapeLock().setSelectLocked(true);
footerShape.getAutoShapeLock().setSizeLocked(true);
footerShape.getAutoShapeLock().setTextLocked(true);
footerShape.getAutoShapeLock().setPositionLocked(true);
footerShape.getAutoShapeLock().setGroupingLocked(true);
// Set the text color for the footer after locking.
IFillFormat fillFormat = paragraph.getParagraphFormat().getDefaultPortionFormat().getFillFormat();
fillFormat.setFillType(FillType.Solid);
fillFormat.getSolidFillColor().setColor(footerColor);
Next Steps
- Run the updated code and check if the footer text color changes to red.
- If the issue persists, inspect the master slide settings to ensure there are no overriding styles.
- Consider testing with a simple presentation to isolate the issue.
Please implement these steps and let me know if you need further assistance!
@Rama_Menon,
Thanks for the details and code snippet.
I am able to reproduce the issue as you mentioned by using your sample code snippet (even I tried other variations with relevant APIs, but to no avail). I found footer text was showing in (default) grey colour in PowerPoint even I set text color to RED in code.
We require thorough evaluation of the issue. 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-39693
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.
@Rama_Menon,
After further evaluation, it appears that this is not an issue with the Aspose.Slides APIs. Instead, we noticed that the footer paragraph formatting in your code snippet was not set correctly. We kindly suggest referring to and trying the following sample code, which should help you adjust the footer text color accurately:
Presentation pres = new Presentation();
// Setting Footer
pres.getHeaderFooterManager().setAllFootersText("My Footer text");
pres.getHeaderFooterManager().setAllFootersVisibility(true);
// Change color on Layout Slides
for (IShape shape : pres.getSlides().get_Item(0).getLayoutSlide().getShapes())
{
if (shape.getPlaceholder() != null)
{
if (shape.getPlaceholder().getType() == PlaceholderType.Footer)
{
((IAutoShape) shape).getTextFrame().setText("HI there new header");
((IAutoShape) shape).getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().
getDefaultPortionFormat().getFillFormat().setFillType(FillType.Solid);
((IAutoShape) shape).getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().
getDefaultPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.GREEN);
}
}
}
// Change color on Slide
for (IShape shape : pres.getSlides().get_Item(0).getShapes())
{
if (shape.getPlaceholder() != null)
{
if (shape.getPlaceholder().getType() == PlaceholderType.Footer)
{
((IAutoShape) shape).getTextFrame().setText("HI there new header");
((IAutoShape) shape).getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().
getDefaultPortionFormat().getFillFormat().setFillType(FillType.Solid);
((IAutoShape) shape).getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().
getDefaultPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.RED);
}
}
}
pres.save("HeaderFooterJava.pptx", SaveFormat.Pptx);
Please find attached the output PPTX file for your reference.
HeaderFooterJava.zip (22.9 KB)
Let us know if we can be of any further help.