Search in sources :

Example 16 with Relationship

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;
}
Also used : Relationship(org.docx4j.relationships.Relationship) HeaderPart(org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart)

Example 17 with Relationship

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"));
}
Also used : P(org.docx4j.wml.P) ObjectFactory(org.docx4j.wml.ObjectFactory) MainDocumentPart(org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart) CTBorder(org.docx4j.wml.CTBorder) Relationship(org.docx4j.relationships.Relationship) BigInteger(java.math.BigInteger) WordprocessingMLPackage(org.docx4j.openpackaging.packages.WordprocessingMLPackage) File(java.io.File)

Example 18 with Relationship

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;
}
Also used : FooterPart(org.docx4j.openpackaging.parts.WordprocessingML.FooterPart) Relationship(org.docx4j.relationships.Relationship)

Example 19 with Relationship

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;
}
Also used : Relationship(org.docx4j.relationships.Relationship) HeaderPart(org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart)

Example 20 with Relationship

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;
}
Also used : FooterPart(org.docx4j.openpackaging.parts.WordprocessingML.FooterPart) Relationship(org.docx4j.relationships.Relationship)

Aggregations

Relationship (org.docx4j.relationships.Relationship)27 FooterPart (org.docx4j.openpackaging.parts.WordprocessingML.FooterPart)7 HeaderPart (org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart)7 File (java.io.File)6 MainDocumentPart (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)4 WordprocessingMLPackage (org.docx4j.openpackaging.packages.WordprocessingMLPackage)3 PartName (org.docx4j.openpackaging.parts.PartName)3 ObjectFactory (org.docx4j.wml.ObjectFactory)3 IOException (java.io.IOException)2 BigInteger (java.math.BigInteger)2 ContentType (org.docx4j.openpackaging.contenttype.ContentType)2 Docx4JException (org.docx4j.openpackaging.exceptions.Docx4JException)2 AlternativeFormatInputPart (org.docx4j.openpackaging.parts.WordprocessingML.AlternativeFormatInputPart)2 CTAltChunk (org.docx4j.wml.CTAltChunk)2 Text (com.vladsch.flexmark.ast.Text)1 AttributesNode (com.vladsch.flexmark.ext.attributes.AttributesNode)1 EnumeratedReferenceText (com.vladsch.flexmark.ext.enumerated.reference.EnumeratedReferenceText)1 FileNotFoundException (java.io.FileNotFoundException)1 JAXBException (javax.xml.bind.JAXBException)1 CTChartSpace (org.docx4j.dml.chart.CTChartSpace)1