Page 1 of 1

How to apply character styles to a word file in docx4j?

PostPosted: Tue Nov 04, 2014 3:17 pm
by shank
I want to read a document by paragraphs and if there comes any text in between " " like quotes, then i have to apply emphasis style to quotes. Is there any way to do this...

Any help would be appreciated...........Thanks

for (Object jaxbNode : jaxbNodes){
String paragraphString = jaxbNode.toString();
styling( paragraphString , true);


for(int i=0;i<s1.length();i++)

{
if(s1.charAt(i)=='“')
{
checkStart=true;
}
if(s1.charAt(i)=='”')
{
checkStart=false;
}
if(checkStart)
{
P paragraph = factory.createP();

Text text = factory.createText();
text.setValue(s1);


R run = factory.createR();
System.out.println(run.getContent().add(text));

// paragraph.getContent().add(run);

RPr r = factory.createRPr();


RStyle rs=factory.createRStyle();
rs.setVal("Emphasis");
r.setRStyle(rs);



run.setRPr(r);

// paragraph.getContent().add(run); addTo.getContent().add(paragraph);

}

}

Re: How to apply character styles to a word file in docx4j?

PostPosted: Wed Nov 05, 2014 4:10 pm
by jason
This post is a duplicate of one on StackOverflow. Locking now; will delete later.