本文整理汇总了Java中org.docx4j.wml.P.setPPr方法的典型用法代码示例。如果您正苦于以下问题:Java P.setPPr方法的具体用法?Java P.setPPr怎么用?Java P.setPPr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.docx4j.wml.P
的用法示例。
在下文中一共展示了P.setPPr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHorizontalLine
import org.docx4j.wml.P; //导入方法依赖的package包/类
public static P createHorizontalLine() {
org.docx4j.wml.ObjectFactory wmlObjectFactory = new org.docx4j.wml.ObjectFactory();
// Create object for p
P p = wmlObjectFactory.createP();
// Create object for pPr
PPr ppr = wmlObjectFactory.createPPr();
p.setPPr(ppr);
// Create object for pBdr
PPrBase.PBdr pprbasepbdr = wmlObjectFactory.createPPrBasePBdr();
ppr.setPBdr(pprbasepbdr);
// Create object for bottom
CTBorder border = wmlObjectFactory.createCTBorder();
pprbasepbdr.setBottom(border);
border.setVal(org.docx4j.wml.STBorder.SINGLE);
border.setSz(BigInteger.valueOf(6));
border.setColor("auto");
border.setSpace(BigInteger.valueOf(1));
return p;
}
示例2: addHeaderParagraphOfText
import org.docx4j.wml.P; //导入方法依赖的package包/类
/**
*
* @param mainDocumentPart
* @param workItemID
* @param simpleText
* @param styleId
* @return
*/
private static P addHeaderParagraphOfText(MainDocumentPart mainDocumentPart, Integer workItemID, String simpleText, String styleId) {
ObjectFactory factory = Context.getWmlObjectFactory();
P p = factory.createP();
if (simpleText!=null) {
Text t = factory.createText();
t.setValue(simpleText);
R run = factory.createR();
run.getContent().add(t);
p.getContent().add(run);
BookmarkAdd.bookmarkRun(p, run, ITEM_BOOKMARK_PREFIX+workItemID, workItemID);
}
if (mainDocumentPart.getPropertyResolver().activateStyle(styleId)) {
// Style is available
org.docx4j.wml.PPr pPr = factory.createPPr();
p.setPPr(pPr);
org.docx4j.wml.PPrBase.PStyle pStyle = factory.createPPrBasePStyle();
pPr.setPStyle(pStyle);
pStyle.setVal(styleId);
} else {
LOGGER.debug("StyleID " + styleId + " not available");
}
return p;
}
示例3: apply
import org.docx4j.wml.P; //导入方法依赖的package包/类
@Override
public void apply(P imageParagraph, Object parent, List<Object> siblings) {
SingleTraversalUtilVisitorCallback imageVisitor = new SingleTraversalUtilVisitorCallback(new TraversalUtilDrawingVisitor());
imageVisitor.walkJAXBElements(imageParagraph);
if (foundDrawingInParagraph) {
ImageOrTableCaption imageCaption = captionsMap.get(captionKey);
if (imageCaption!=null) {
//add only for imageCaptionsMap contents i.e. programmatically added images (not for eventually existing images in word template)
P captionParagraph = createCaption(figurePrefix, imageCaption, captionStyleId);
ContentAccessor contentAccessor = (ContentAccessor)parent;
List<Object> contentList = contentAccessor.getContent();
for (int i = 0; i < contentList.size(); i++) {
Object object = contentList.get(i);
if (imageParagraph.equals(object)) {
//align to center
imageParagraph.setPPr(setAlignment(imageCaption.getAlign()));
imageParagraphToCaptionParagraphMap.put(imageParagraph, captionParagraph);
imageParagraphToParentMap.put(imageParagraph, contentAccessor);
break;
}
}
}
}
foundDrawingInParagraph = false;
captionKey = null;
}
示例4: createPageNumParagraph
import org.docx4j.wml.P; //导入方法依赖的package包/类
private P createPageNumParagraph() {
CTSimpleField pgnum = factory.createCTSimpleField();
pgnum.setInstr(" PAGE \\* MERGEFORMAT ");
RPr RPr = factory.createRPr();
RPr.setNoProof(new BooleanDefaultTrue());
PPr ppr = factory.createPPr();
Jc jc = factory.createJc();
jc.setVal(JcEnumeration.CENTER);
ppr.setJc(jc);
PPrBase.Spacing pprbase = factory.createPPrBaseSpacing();
pprbase.setBefore(BigInteger.valueOf(240));
pprbase.setAfter(BigInteger.valueOf(0));
ppr.setSpacing(pprbase);
R run = factory.createR();
run.getContent().add(RPr);
pgnum.getContent().add(run);
JAXBElement<CTSimpleField> fldSimple = factory.createPFldSimple(pgnum);
P para = createParagraph();
para.getContent().add(fldSimple);
para.setPPr(ppr);
return para;
}
示例5: createParagraphWithHAlign
import org.docx4j.wml.P; //导入方法依赖的package包/类
/**
* 创建段落设置水平对齐方式
* @return
*/
private P createParagraphWithHAlign() {
P p;
PPr pPr;
p = Docx4j_Helper.factory.createP();
pPr=Docx4j_Helper.factory.createPPr();
Jc jc =Docx4j_Helper.factory.createJc();
jc.setVal(JcEnumeration.CENTER);
pPr.setJc(jc);
p.setPPr(pPr);
return p;
}
示例6: createParagraghLine
import org.docx4j.wml.P; //导入方法依赖的package包/类
public void createParagraghLine(WordprocessingMLPackage wordMLPackage,
MainDocumentPart t, ObjectFactory factory,P p,CTBorder topBorder,CTBorder bottomBorder,CTBorder leftBorder,CTBorder rightBorder){
PPr ppr=new PPr();
PBdr pBdr=new PBdr();
pBdr.setTop(topBorder);
pBdr.setBottom(bottomBorder);
pBdr.setLeft(leftBorder);
pBdr.setRight(rightBorder);
ppr.setPBdr(pBdr);
p.setPPr(ppr);
}
示例7: setParagraphShdStyle
import org.docx4j.wml.P; //导入方法依赖的package包/类
public void setParagraphShdStyle(ObjectFactory factory, P p, boolean isShd,
STShd shdValue, String shdColor) {
if (isShd) {
PPr ppr = factory.createPPr();
CTShd shd = new CTShd();
if (shdColor != null) {
shd.setColor(shdColor);
}
if (shdValue != null) {
shd.setVal(shdValue);
}
ppr.setShd(shd);
p.setPPr(ppr);
}
}
示例8: setParagraphSpacing
import org.docx4j.wml.P; //导入方法依赖的package包/类
public void setParagraphSpacing(ObjectFactory factory, P p,
boolean isSpace, String before, String after, boolean isLines,
String beforeLines, String afterLines, boolean isLineRule,
String lineValue, STLineSpacingRule sTLineSpacingRule) {
PPr pPr = p.getPPr();
if (pPr == null) {
pPr = factory.createPPr();
}
Spacing spacing = new Spacing();
if (isSpace) {
if (before != null) {
// 段前磅数
spacing.setBefore(new BigInteger(before));
}
if (after != null) {
// 段后磅数
spacing.setAfter(new BigInteger(after));
}
}
if (isLines) {
if (beforeLines != null) {
// 段前行数
spacing.setBeforeLines(new BigInteger(beforeLines));
}
if (afterLines != null) {
// 段后行数
spacing.setAfterLines(new BigInteger(afterLines));
}
}
if (isLineRule) {
if (lineValue != null) {
spacing.setLine(new BigInteger(lineValue));
}
spacing.setLineRule(sTLineSpacingRule);
}
pPr.setSpacing(spacing);
p.setPPr(pPr);
}
示例9: setHorizontalAlignment
import org.docx4j.wml.P; //导入方法依赖的package包/类
public void setHorizontalAlignment(P paragraph, JcEnumeration hAlign) {
if (hAlign != null) {
PPr pprop = new PPr();
Jc align = new Jc();
align.setVal(hAlign);
pprop.setJc(align);
paragraph.setPPr(pprop);
}
}
示例10: createFillerP
import org.docx4j.wml.P; //导入方法依赖的package包/类
private static P createFillerP() {
org.docx4j.wml.ObjectFactory wmlObjectFactory = Context.getWmlObjectFactory();
P p = wmlObjectFactory.createP();
// Create object for pPr
PPr ppr = wmlObjectFactory.createPPr();
p.setPPr(ppr);
// Create object for rPr
ParaRPr pararpr = wmlObjectFactory.createParaRPr();
// Create object for spacing
PPrBase.Spacing pprbasespacing = wmlObjectFactory.createPPrBaseSpacing();
ppr.setSpacing(pprbasespacing);
pprbasespacing.setBefore( BigInteger.valueOf( 800) );
pprbasespacing.setAfter( BigInteger.valueOf( 800) );
// Create object for r
R r = wmlObjectFactory.createR();
p.getContent().add( r);
// Create object for rPr
RPr rpr = wmlObjectFactory.createRPr();
r.setRPr(rpr);
// Create object for sz
HpsMeasure hpsmeasure3 = wmlObjectFactory.createHpsMeasure();
rpr.setSz(hpsmeasure3);
hpsmeasure3.setVal( BigInteger.valueOf( 96) );
// Create object for t (wrapped in JAXBElement)
Text text = wmlObjectFactory.createText();
JAXBElement<org.docx4j.wml.Text> textWrapped = wmlObjectFactory.createRT(text);
r.getContent().add( textWrapped);
text.setValue( "BODY CONTENT");
return p;
}
示例11: createParagraph
import org.docx4j.wml.P; //导入方法依赖的package包/类
private P createParagraph(final String styleId, final R... runs) {
final P p = this.wmlObjectFactory.createP();
final PPr ppr = this.wmlObjectFactory.createPPr();
p.setPPr(ppr);
final PStyle pstyle = this.wmlObjectFactory.createPPrBasePStyle();
pstyle.setVal(styleId);
ppr.setPStyle(pstyle);
p.getContent().addAll(Arrays.asList(runs));
return p;
}
示例12: generateCommentContent
import org.docx4j.wml.P; //导入方法依赖的package包/类
private P generateCommentContent(final String content) {
final P paragraph = this.wmlObjectFactory.createP();
final PPr paragraphProperties = this.wmlObjectFactory.createPPr();
paragraph.setPPr(paragraphProperties);
paragraph.getContent().add(createRunWithContent(Collections.singletonList(createTextElement(content)), this.wmlObjectFactory.createRPr()));
return paragraph;
}
示例13: apply
import org.docx4j.wml.P; //导入方法依赖的package包/类
@Override
public void apply(P p, Object parent, List<Object> siblings) {
//apply the inline style for each run
SingleTraversalUtilVisitorCallback runVisitor = new SingleTraversalUtilVisitorCallback(new TraversalUtilRunVisitor());
runVisitor.walkJAXBElements(p);
ObjectFactory wmlObjectFactory = new ObjectFactory();
PPr ppr = p.getPPr();
if (ppr==null) {
ppr = wmlObjectFactory.createPPr();
p.setPPr(ppr);
}
//apply the inline style for run at paragraph level
if (runWithTextFound) {
if (inlineContentStyleIsParagraphStyle) {
// Create object for pStyle
PPrBase.PStyle pprbasepstyle = wmlObjectFactory.createPPrBasePStyle();
ppr.setPStyle(pprbasepstyle);
pprbasepstyle.setVal(inlineStyleId);
} else {
// Create object for rStyle
RStyle rstyle = wmlObjectFactory.createRStyle();
ParaRPr paraRpr = ppr.getRPr();
if (paraRpr==null) {
paraRpr = wmlObjectFactory.createParaRPr();
ppr.setRPr(paraRpr);
}
paraRpr.setRStyle(rstyle);
rstyle.setVal(inlineStyleId);
}
}
runWithTextFound = false;
}
示例14: createParagraph
import org.docx4j.wml.P; //导入方法依赖的package包/类
private P createParagraph(BandElement be) {
P paragraph = factory.createP();
PPr pPr = factory.createPPr();
Spacing spacing = new Spacing();
if ((be!= null) && be.isWrapText() && (be.getPercentLineSpacing() > 100)) {
spacing.setLine( BigInteger.valueOf( (be.getFont().getSize() * be.getPercentLineSpacing())/2) );
}
spacing.setAfter(BigInteger.ZERO);
pPr.setSpacing(spacing);
paragraph.setPPr(pPr);
return paragraph;
}
示例15: testDocx4jSetPageSize
import org.docx4j.wml.P; //导入方法依赖的package包/类
public void testDocx4jSetPageSize() throws Exception {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
String titleStr="静夜思 李白";
String str="床前明月光,疑似地上霜。";
String str2="举头望明月,低头思故乡。";
P p = Docx4j_Helper.factory.createP();
String rprStr = "<w:rPr xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:rFonts w:hint=\"eastAsia\" w:ascii=\"Times New Roman\" w:hAnsi=\"Times New Roman\" w:eastAsia=\"宋体\"/><w:b/><w:color w:val=\"333333\"/><w:sz w:val=\"32\"/><w:szCs w:val=\"32\"/></w:rPr>";
RPr rpr = (RPr) XmlUtils.unmarshalString(rprStr);
setParagraphContent(p, rpr,titleStr);
mdp.addObject(p);
p = Docx4j_Helper.factory.createP();
setParagraphContent(p, rpr,str);
mdp.addObject(p);
p = Docx4j_Helper.factory.createP();
PPr pPr=Docx4j_Helper.factory.createPPr();
//设置文字方向
SectPr sectPr = Docx4j_Helper.factory.createSectPr();
TextDirection textDirect = Docx4j_Helper.factory.createTextDirection();
//文字方向:垂直方向从右往左
textDirect.setVal("tbRl");
sectPr.setTextDirection(textDirect);
Type sectType = Docx4j_Helper.factory.createSectPrType();
//下一页
sectType.setVal("nextPage");
sectPr.setType(sectType);
//设置页面大小
PgSz pgSz = Docx4j_Helper.factory.createSectPrPgSz();
pgSz.setW(new BigInteger("8335"));
pgSz.setH(new BigInteger("11850"));
sectPr.setPgSz(pgSz);
pPr.setSectPr(sectPr);
p.setPPr(pPr);
setParagraphContent(p, rpr,str2);
mdp.addObject(p);
p = createParagraphWithHAlign();
setParagraphContent(p, rpr,titleStr);
mdp.addObject(p);
p = createParagraphWithHAlign();
setParagraphContent(p, rpr,str);
mdp.addObject(p);
p = createParagraphWithHAlign();
setParagraphContent(p, rpr,str2);
mdp.addObject(p);
Docx4j_Helper.saveWordPackage(wordMLPackage, outputfilepath);
}