Header text

Hi,

I have a problem with text from header, I extract text, work with him and than write to document, and than when open document in Word I don’t see changes in header text. Can You help me with this?

public class Header {

@Test

public void test() throws Exception {

Document document=new Document(“DOC-kraci.docx”);

TestVisitor visitor = new TestVisitor(document);

document.accept(visitor);

document.save(“T-DOC-kraci.docx”);

}

}

public class TestVisitor extends DocumentVisitor {

DocumentBuilder docB;

public TestVisitor(Document documente) {

super();

this.docB = new DocumentBuilder(documente);

docB.moveToDocumentStart();

}

@Override

public int visitRun(Run run) throws Exception {

String text = run.getText();

run.setText(“T” + text);

return super.visitRun(run);

}

}

Hi Djordje,

Thanks for your inquiry.

I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-9432. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Djordje,

It is to inform you that our development
team has completed the work on the issue (WORDSNET-9432) and has come to
a conclusion that this issue and the undesired behavior you’re
observing is actually not a bug in Aspose.Words. So, we have closed this
issue as ‘Not a Bug’.

The text ‘Ultimate test Docx file’ in the header of document is inside content control (StructuredDocumentTag). StructuredDocumentTag
is populated from docProps\core.xml during opening document. Please
unzip .docx file and check how SDT is populated (see
w:dataBinding in header2.xml).


Please open your document in MS Word, copy the same content control from header into body of document and edit the content control. Both content control will have same contents. Please check the attached document for your kind reference.

Hi Djordje,

Further to my last post, Aspose.Words does not support the Data Binding of such SDT or content control at the moment. However, we had already logged this feature request as WORDSNET-6284 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-6284) have been fixed in this Aspose.Words for .NET 21.5 update and this Aspose.Words for Java 21.5 update.