use of org.docx4j.relationships.Relationship in project docx4j-template by vindell.
the class Docx4J_例子2 method createTextHeaderPart.
// 文字页面
public Relationship createTextHeaderPart(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory, String content, boolean isUnderLine, String underLineSz, JcEnumeration jcEnumeration) throws Exception {
HeaderPart headerPart = new HeaderPart();
Relationship rel = t.addTargetPart(headerPart);
headerPart.setJaxbElement(getTextHdr(wordprocessingMLPackage, factory, headerPart, content, isUnderLine, underLineSz, jcEnumeration));
return rel;
}
use of org.docx4j.relationships.Relationship in project docx4j-template by vindell.
the class Docx4J_例子2 method main.
public static void main(String[] args) throws Exception {
Docx4J_例子2 t = new Docx4J_例子2();
WordprocessingMLPackage wordMLPackage = t.createWordprocessingMLPackage();
MainDocumentPart mp = wordMLPackage.getMainDocumentPart();
ObjectFactory factory = Context.getWmlObjectFactory();
Relationship relationship = t.createHeaderPart(wordMLPackage, mp, factory, false, "3");
relationship = t.createTextHeaderPart(wordMLPackage, mp, factory, "我是页眉,独乐乐不如众乐乐", true, "3", JcEnumeration.CENTER);
t.addParagraphTest(wordMLPackage, mp, factory);
t.addPageBreak(wordMLPackage, factory, STBrType.PAGE);
t.createHeaderReference(wordMLPackage, mp, factory, relationship);
t.createNormalTableTest(wordMLPackage, mp, factory);
t.addPageBreak(wordMLPackage, factory, STBrType.TEXT_WRAPPING);
t.createTableTest(wordMLPackage, mp, factory);
t.addPageBreak(wordMLPackage, factory, STBrType.TEXT_WRAPPING);
P paragraph = factory.createP();
CTBorder topBorder = new CTBorder();
topBorder.setSpace(new BigInteger("1"));
topBorder.setSz(new BigInteger("2"));
topBorder.setVal(STBorder.WAVE);
t.createParagraghLine(wordMLPackage, mp, factory, paragraph, topBorder, topBorder, topBorder, topBorder);
mp.addObject(paragraph);
t.createHyperlink(wordMLPackage, mp, factory, paragraph, "mailto:1329186624@qq.com?subject=docx4j测试", "联系我", "微软雅黑", "24", JcEnumeration.CENTER);
// 页脚
// relationship = t.createFooterPart(wordMLPackage, mp, factory,
// false,"3");
// relationship = t.createTextFooterPart(wordMLPackage, mp,
// factory,"我是页脚", true, "3", JcEnumeration.CENTER);
relationship = t.createFooterPageNumPart(wordMLPackage, mp, factory, false, "3", JcEnumeration.CENTER);
t.createFooterReference(wordMLPackage, mp, factory, relationship);
t.saveWordPackage(wordMLPackage, new File("f:/saveFile/temp/s7_simple.docx"));
}
use of org.docx4j.relationships.Relationship in project docx4j-template by vindell.
the class Docx4J_例子2 method createFooterPart.
// 图片页脚
public Relationship createFooterPart(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory, boolean isUnderLine, String underLineSize) throws Exception {
FooterPart footerPart = new FooterPart();
Relationship rel = t.addTargetPart(footerPart);
footerPart.setJaxbElement(getFtr(wordprocessingMLPackage, factory, footerPart, isUnderLine, underLineSize));
return rel;
}
use of org.docx4j.relationships.Relationship in project docx4j-template by vindell.
the class Docx4J_例子2 method createHeaderPart.
// 图片页眉
public Relationship createHeaderPart(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory, boolean isUnderLine, String underLineSize) throws Exception {
HeaderPart headerPart = new HeaderPart();
Relationship rel = t.addTargetPart(headerPart);
// After addTargetPart, so image can be added properly
headerPart.setJaxbElement(getHdr(wordprocessingMLPackage, factory, headerPart, isUnderLine, underLineSize));
return rel;
}
use of org.docx4j.relationships.Relationship in project docx4j-template by vindell.
the class Docx4J_简单例子 method createFooterPart.
// 图片页脚
public Relationship createFooterPart(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory) throws Exception {
FooterPart footerPart = new FooterPart();
Relationship rel = t.addTargetPart(footerPart);
footerPart.setJaxbElement(getFtr(wordprocessingMLPackage, factory, footerPart));
return rel;
}
Aggregations