We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Table cell text font issue

Hi,


I have Word document with table, and as You can see first cell text is bolded. When I use following code:

import org.junit.Test;

import com.aspose.words.Document;
import com.aspose.words.DocumentVisitor;
import com.aspose.words.Run;

public class TestBold {

class DocVisit extends DocumentVisitor {
public int visitRun(Run run) throws Exception {
if (run.getText().startsWith(“Name of Award”)) {
System.out.println("BOLD: " + run.getFont().getBold());
}

return super.visitRun(run);
}
}

@Test
public void test() throws Exception {
Document doc = new Document(
“bold-test.docx”);

doc.accept(new DocVisit());
}
}

I am getting following output:

BOLD: false

Word file is attached to this post too. Can You help me here? Note that I am using Aspose.Words for Java 14.3.0

Best regards,
Zeljko

Hi Zeljko,


Thanks for your inquiry. I tested the scenario and have managed to reproduce the same problem. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-11540. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

Thaks Awais!


Best regards,
Zeljko

Hi, I need to report another issue regarding text color in table cell. In the attached document, the color of the word “Public” is white, but with the code below I get it black.


Document document = new Document(“NTRL_ACCESS_CHART_No_Future.docx”);
DocumentBuilder builder = new DocumentBuilder(document);

NodeCollection nodes = document.getChildNodes(NodeType.RUN, true);

Node node = nodes.get(1);

builder.moveTo(node);
Font font = builder.getFont();

System.out.println(node.getText());
System.out.println("Color: " + font.getColor().toString());

I’m using Aspose.Words 15.6.0.

Thanks,
Zeljko
Hi Zeljko,

Thanks for your inquiry.

The style "Light List - Accent 1" is applied to this table. As a workaround you can convert formatting specified in table styles into direct formatting on tables in the document. After calling the following method, you can access the correct Font information using normal API:

Document document = new Document("NTRL_ACCESS_CHART_No_Future.docx");
document.expandTableStylesToDirectFormatting();

DocumentBuilder builder = new DocumentBuilder(document);
...
...

I hope, this helps.

Best regards,

The issues you have found earlier (filed as WORDSNET-11540) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.