Page 1 of 1

Bullet Points Not getting generated

PostPosted: Thu Oct 09, 2014 11:51 pm
by Vijayakumar17
Hi Team,

I am trying to generate a word document from scratch using Docx4j. I was able to generate tables, content within tables. Now I am trying to display the content within the table as BULLET points in the below attached format.

I am using the below mentioned code.

Code: Select all
public static P getTaskWithBulletin(String tempStr, ObjectFactory factory){
      P p = factory.createP();
      PPr ppr = factory.createPPr();
      PStyle pstyle = factory.createPPrBasePStyle();
      

      NumPr numpr =  factory.createPPrBaseNumPr();
      
      
      NumId numIdElement = factory.createPPrBaseNumPrNumId();
      numpr.setNumId(numIdElement);
      numpr.getNumId().setVal(BigInteger.valueOf(0));
      
       // The <w:ilvl> element
       Ilvl ilvlElement = factory.createPPrBaseNumPrIlvl();
       numpr.setIlvl(ilvlElement);
       numpr.getIlvl().setVal(BigInteger.valueOf(0));
      
       ppr.setNumPr(numpr);
      
      pstyle.setVal("ListParagraph");
      ppr.setPStyle(pstyle);
      p.setPPr(ppr);
      
      org.docx4j.wml.Text t = factory.createText();
      t.setValue(tempStr);

      org.docx4j.wml.R run = factory.createR();
      run.getContent().add(t);

      p.getContent().add(run);
      return p;      
      
   }



But I am NOT getting the bullet Points. I DONT want bullet points to be numbered as 1 , 2 , 3.

Kindly Help.

Thanks
Vijay

Re: Bullet Points Not getting generated

PostPosted: Fri Oct 10, 2014 7:17 am
by jason
numId (and level) must point to a bulleted list defined in your numbering definitions part.

Note the distinction between abstract and instance definitions: The numbering definition instance reference specifies the given numbering definition instance to be applied to the given paragraph, which itself inherits its properties from an abstract numbering definition

http://webapp.docx4java.org/OnlineDemo/ ... numId.html

http://webapp.docx4java.org/OnlineDemo/ ... numPr.html

Re: Bullet Points Not getting generated

PostPosted: Mon Oct 27, 2014 11:48 pm
by Vijayakumar17
Hi Jason,

Thanks for the reply. I tried using the following code but now I am getting only decimals. I dont want decimals. I want unordered list bullets points in diamond shape as attached in the previous post.

Code: Select all
NumId numIdElement = factory.createPPrBaseNumPrNumId();
      numpr.setNumId(numIdElement);
      numpr.getNumId().setVal(BigInteger.valueOf(0));
      
       // The <w:ilvl> element
       Ilvl ilvlElement = factory.createPPrBaseNumPrIlvl();
       numpr.setIlvl(ilvlElement);
       numpr.getIlvl().setVal(BigInteger.valueOf(0));


Kindly do the needful. If you have any sample code please share that too.

Thanks
Vijay

Re: Bullet Points Not getting generated

PostPosted: Tue Oct 28, 2014 12:36 am
by jason
Well you need to ensure a suitable definition is present in your Numbering Definitions Part (NDP), then point at it.

Easiest to create a suitable sample docx in Word, then save it. (You can upload it to the online webapp, to generate code from the NDP)