Free Support Forum - aspose.com

Hidden text not detected

Hi, when I insert field like:
Document document = new Document();

DocumentBuilder builder = new DocumentBuilder(document);

FieldStart start = builder.insertField(“TC “test””, null);

and if I check if it is hidden:

boolean hidden = builder.getFont().getHidden();

it returns false to me but that part of text is hidden in word.

I’m using aspose.word for java.

Thanks, Ivica.

Hi

Thanks for your inquiry. I think that if you insert TC field into the document there is no hidden text. TC field is inserted as special character and you can’t see its code in the document (click this button “” to see its code).

Select inserted field, right click on it, select “Font” from context menu and you can see that font is not hidden.

Also you can attach your document for investigating.

Best regards.

Ok, here is what I am trying to do, to insert field of type SEQUENCE inside of field of type TC, and here is part of my code:
Document document = new Document();

DocumentBuilder builder = new DocumentBuilder(document);

String nestedCode = “seq Figure\c”;

String tcStart = “TC”;

FieldStart start = builder.insertField(“TC “test” \f f”, null);

Run run = new Run(document);

run.setText(tcStart);

builder.getCurrentParagraph().insertAfter(run, start);

Run nextRun = (Run)run.getNextSibling();

nextRun.setText(nextRun.getText().replace(tcStart, “”));

builder.moveTo(run.getNextSibling());

builder.write(" ");

builder.insertField(nestedCode, null);

and now my problem is that inserted string “TC” is now visible in output document but has to be invisible.

There is source sample document in attachment.

Thanks, Ivica.

Hi

Thanks for additional information. Maybe the following code could help you.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

String nestedCode = "SEQ Figure\\c";

String tcCode = "TC \"test\" \\f f";

FieldStart start = builder.insertField(tcCode, null);

builder.moveTo(start.getNextSibling());

builder.insertField(nestedCode, null);

doc.save("out.doc");

Best regards.

Hi,

no, this code adds nestedCode just after fieldStart and before “TC “test” \f f”, but I need something like thie “TC “{SEQ Figure\c} test” \f f”.

Thanks, Ivica.

Hi

I think that the following code should help you.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

String nestedCode = "SEQ Figure\\c";

String tcCode = "TC \"test\" \\f f";

FieldStart start = builder.insertField(tcCode, null);

Run tcCodeRun = (Run)start.getNextSibling();

tcCodeRun.setText(tcCodeRun.getText().replace("TC", ""));

builder.moveTo(start.getNextSibling());

builder.write("TC");

builder.insertField(nestedCode, null);

doc.save("out.doc");

Best regards.

Yes, that is it!

Thanks.