简体   繁体   中英

How to change the font color of Header and Footer Text (which is merge field) and exist Line color change in Aspose Word Java

I have an existing Aspose word template, I want to change the font color of the text in header and footer which is merge field value.

Also, I have exist line (shape), I want to change the color of this line. How can I achieve it?

Color of text can be changed using Run.Font.Color property. You can get Run nodes in any headers/footers and change text color using the following code:

HeaderFooter primaryHeader = doc.getFirstSection().getHeadersFooters().
        getByHeaderFooterType(HeaderFooterType.HEADER_PRIMARY);
for (Run run : (Iterable<Run>) primaryHeader.getChildNodes(NodeType.RUN, true)){
    run.getFont().setColor(Color.RED);
}

Using Aspose.Words for Java , you can also change stroke color of Shape using the following code:

for (Shape shape : (Iterable<Shape>) doc.getChildNodes(NodeType.SHAPE, true)){
    shape.setStrokeColor(Color.RED);
}

I work with Aspose as Developer Evangelist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM