Free Support Forum -

Header Color Error

Hi, I’m having a bug with Aspose API when converting to a word doc from a template file. So the document keeps displaying red text in the header when it is supposed to be black by default.

Original template:
template.JPG (30.4 KB)

Template with bookmark:
Contract1.JPG (36.6 KB)

The code:
public class Watermark {

private String watermarkPath = GlobalPath.watermarkImage;

public void addWatermark(Document document) throws Exception {
	 Shape watermark = new Shape(document, ShapeType.IMAGE); //TEXT_PLAIN_TEXT


        // Place the watermark in the page center.

        // Create a new paragraph and append the watermark to this paragraph.
        Paragraph watermarkPara = new Paragraph(document);

        // Insert the watermark into all headers of each document section.
        for (Section sect : document.getSections()){
            // There could be up to three different headers in each section, since we want
            // the watermark to appear on all pages, insert into all headers.
            insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HEADER_PRIMARY);
            insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HEADER_FIRST);
            insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HEADER_EVEN);

@SuppressWarnings({ "unchecked" })
public void removeWatermark(Document document) {
	NodeCollection<Node> shapesColl = document.getChildNodes(NodeType.SHAPE, true, false);
    Node[] shapesArray = shapesColl.toArray();
    for (int i = 0; i < shapesArray.length; i++)
        Shape shape = (Shape) shapesArray[i];
        	// if (shape.getImageData().getTitle().equalsIgnoreCase("watermark")){
        		if (shape.getHeight() == 500 && shape.getWidth() == 500){
        	// }

 private void insertWatermarkIntoHeader(Paragraph watermarkPara, Section sect, int headerType) throws Exception {
        HeaderFooter header = sect.getHeadersFooters().getByHeaderFooterType(headerType);

        if (header == null){
            // There is no header of the specified type in the current section, create it.
            header = new HeaderFooter(sect.getDocument(), headerType);
        // Insert a clone of the watermark into the header.

public String getWatermarkPath() {
	return watermarkPath;

public void setWatermarkPath(String watermarkPath) {
	this.watermarkPath = watermarkPath;



Thanks for your inquiry. Please ZIP and upload your input Word document and Aspose.Words generated output Word document (.docx file) showing the undesired behavior here for testing. We will investigate the issue on our end and provide you more information.

Hey Awais, I attached the input word document and aspose.words generated output document. Thank you for your help. (332.9 KB)


Thanks for your inquiry. After an initial test with the licensed latest version of Aspose.Words for Java i.e. 18.7, we were unable to reproduce this issue on our end. Please see output document ( (162.5 KB)). We used the code from your first post on our end to produce this output.