I wanted to get all page macros and get their body to use it for other pages.
@ComponentImport final XhtmlContent xhtmlContent
public List<MacroDefinition> getPageMacros() throws XhtmlException {
if (xhtmlContent != null) {
final List<MacroDefinition> macros = new ArrayList<MacroDefinition>();
ContentEntityObject page = conversionContext.getEntity();
String pageContent = page.getBodyAsString();
xhtmlContent.handleMacroDefinitions(pageContent, conversionContext, new MacroDefinitionHandler() {
public void handle(MacroDefinition macroDefinition) {
macros.add(macroDefinition);
}
});
return macros;
}
return Collections.EMPTY_LIST;
}
I found this. Maybe this could help some other users.