Page 1 of 1

Generating horizontal line

PostPosted: Thu Aug 15, 2013 1:20 am
by utaylsa
Here is how you can generate a horizontal line:

Simply add the horizontal line to a P and

ENJOY!!
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
        /**
         * Generate a horizontal line
         * @return
         * @throws JAXBException
         */

        public static P generateHorizontalLine() throws JAXBException {
                 ObjectFactory factory = new ObjectFactory();
         P  p = factory.createP();
         PPr  pPr = factory.createPPr();
         p.setPPr(pPr);
         PPrBase.PBdr bdr = factory.createPPrBasePBdr();
         CTBorder bottom = factory.createCTBorder();                  
         pPr.setPBdr(bdr);
         bdr.setBottom(bottom);
         bottom.setVal( org.docx4j.wml.STBorder.SINGLE );
         bottom.setSz( new java.math.BigInteger("6")); //yuck
         bottom.setSpace(new java.math.BigInteger("1"));
         bottom.setColor("auto");
                return p;
        }

 
Parsed in 0.016 seconds, using GeSHi 1.0.8.4


Here is how you can use it:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting

        P paragraph = TextWithStyle.generateParagraphHeader("Header");
                wordMLPackage.getMainDocumentPart().getJaxbElement().getBody()
                                .getContent().add(paragraph);
 
Parsed in 0.013 seconds, using GeSHi 1.0.8.4