Page 1 of 1

Setting font size etc.

PostPosted: Mon Apr 15, 2013 8:52 pm
by lazywednesday
I have this code and i have been working on this for hours. the program runs properly but it just wont work. its just setting the run size.
here's the code.

Code: Select all
P pDate = factory.createP();
R rDate = factory.createR();
RPr sample = factory.createRPr();

HpsMeasure size = new HpsMeasure();
size.setVal(BigInteger.valueOf(21));
sample.setSz(size);
rDate.setRPr(sample);
rDate.getContent().add(wordMLPackage.getMainDocumentPart().createParagraphOfText("sample date"));

pDate.getContent().add(rDate);


this is just the part of the code where i added the paragraph and all. it displays the "sample date" but the size didn't change. thanks in advance

Re: Setting font size etc.

PostPosted: Tue Apr 16, 2013 10:51 pm
by jason
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
P pDate = factory.createP();
R rDate = factory.createR();
RPr sample = factory.createRPr();

HpsMeasure size = new HpsMeasure();
size.setVal(BigInteger.valueOf(21));
sample.setSz(size);
rDate.setRPr(sample);
//rDate.getContent().add(wordMLPackage.getMainDocumentPart().createParagraphOfText("sample date"));

pDate.getContent().add(rDate);

// You still need to add <w:t>sample date</w:t>
// See sample CreateWordprocessingMLDocument

                org.docx4j.wml.Text  t = factory.createText();
                t.setValue("sample date");

                rDate.getContent().add(t);             

// Now add the paragraph to the document
                MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
mdp.getContent().add(pDate);
 
Parsed in 0.016 seconds, using GeSHi 1.0.8.4