Does anyone have an idea how we can add outlines to text (text outline) within powerpoint templates (ppxt) using Apache POI? What I have gathered so far is that the XSLFTextRun class does not have a method to get/ set the text outline for a given run element.
And as such, I could only persist the following font/ text styles:
def fontStyles(textBox: XSLFTextBox, textRun: XSLFTextRun): Unit = {
val fontFamily = textRun.getFontFamily
val fontColor = textRun.getFontColor
val fontSize = textRun.getFontSize
val fontBold = textRun.isBold
val fontItalic = textRun.isItalic
val textAlign = textRun.getParagraph.getTextAlign
textBox.getTextParagraphs.foreach { p =>
p.getTextRuns.foreach { tr =>
tr.setFontFamily(fontFamily)
tr.setFontColor(fontColor)
tr.setFontSize(fontSize)
tr.setBold(fontBold)
tr.setItalic(fontItalic)
tr.getParagraph.setTextAlign(textAlign)
}
}
}
Is it possible to add text outline?
Any assistance/ suggestions would be highly appreciated.
Apache poiuses underlyingooxml-schemasclasses. Those are auto generated fromOffice Open XMLstandard. So they are more complete than the high levelXSLFclasses. Of course they are much less convenient.So if somewhat is not implemented in high level
XSLFclasses, we can get the underlyingCTclasses and do it using those. In case ofXSLFTextRunwe can get theCTRegularTextRunobject. Then we can look whether there are run properties already. If not, we add one. Then we look whether there is outline set already. If so, we unset it, because we want set it new. Then we set a new outline. This simply is a line having a special color. That line is represented byCTLinePropertiesobject. So we need to have methods to create thatCTLineProperties, to setCTLinePropertiesto theXSLFTextRunand getCTLinePropertiesfromXSLFTextRun.Complete example using
Javacode:Tested and works using current
apache poi 5.0.0.