Is it possible to set bold to true and false in one run?
I have the following code on the moment :
XWPFParagraph paragraph = nieuwDocument.createParagraph();
XWPFRun run = paragraph.createRun();
run.setBold(true);
for (XWPFParagraph paragraphs: paragraphList)
{
if(paragraphs.getStyle() !=null)
{
if(paragraphs.getStyle().equals(kop) || paragraphs.getStyle().equals(tussenkop))
{
run.addBreak();
run.setText(paragraphs.getText());
run.addCarriageReturn();
}
if(paragraphs.getNumFmt() != null)
{
//run.setBold(false)
run.addTab();
run.setText(paragraphs.getText());
run.addCarriageReturn();
}
}
I have tried to add run.setBold(false)
into if(paragraphs.getNumFmt() != null)
statement but then all the text is flat again.
I would like the text from the last if
statement flat and from the first if
bold.
Update (with 2 different runs)
If I create two runs my text order is going wrong.
XWPFRun run = paragraph.createRun();
run.setBold(true);
XWPFRun runTwo = paragraph.createRun();
runTwo.setBold(false);
for (XWPFParagraph paragraphs: paragraphList)
{
if(paragraphs.getStyle() !=null)
{
if(paragraphs.getStyle().equals(kop) || paragraphs.getStyle().equals(tussenkop))
{
run.addBreak();
run.setText(paragraphs.getText());
run.addCarriageReturn();
}
if(paragraphs.getNumFmt() != null)
{
runTwo.addTab();
runTwo.setText(paragraphs.getText());
runTwo.addCarriageReturn();
}
Wrong order (second code with two runs
Hope this make it clearer