Search in sources :

Example 1 with Relationship

use of org.docx4j.relationships.Relationship in project docx4j-template by vindell.

the class Docx4J_简单例子 method createTextHeaderPart.

// 文字页面
public Relationship createTextHeaderPart(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory, String content, JcEnumeration jcEnumeration) throws Exception {
    HeaderPart headerPart = new HeaderPart();
    Relationship rel = t.addTargetPart(headerPart);
    headerPart.setJaxbElement(getTextHdr(wordprocessingMLPackage, factory, headerPart, content, jcEnumeration));
    return rel;
}
Also used : Relationship(org.docx4j.relationships.Relationship) HeaderPart(org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart)

Example 2 with Relationship

use of org.docx4j.relationships.Relationship in project docx4j-template by vindell.

the class Docx4J_简单例子 method createTextFooterPart.

// 文字页脚
public Relationship createTextFooterPart(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory, String content, JcEnumeration jcEnumeration) throws Exception {
    FooterPart footerPart = new FooterPart();
    Relationship rel = t.addTargetPart(footerPart);
    footerPart.setJaxbElement(getTextFtr(wordprocessingMLPackage, factory, footerPart, content, jcEnumeration));
    return rel;
}
Also used : FooterPart(org.docx4j.openpackaging.parts.WordprocessingML.FooterPart) Relationship(org.docx4j.relationships.Relationship)

Example 3 with Relationship

use of org.docx4j.relationships.Relationship in project docx4j-template by vindell.

the class Docx4J_简单例子 method main.

public static void main(String[] args) throws Exception {
    Docx4J_简单例子 t = new Docx4J_简单例子();
    WordprocessingMLPackage wordMLPackage = t.createWordprocessingMLPackage();
    MainDocumentPart mp = wordMLPackage.getMainDocumentPart();
    ObjectFactory factory = Context.getWmlObjectFactory();
    // 页眉
    Relationship relationship = t.createHeaderPart(wordMLPackage, mp, factory);
    t.createHeaderReference(wordMLPackage, mp, factory, relationship);
    t.addParagraphTest(wordMLPackage, mp, factory);
    t.addPageBreak(wordMLPackage, factory);
    // 页脚
    t.createNormalTableTest(wordMLPackage, mp, factory);
    relationship = t.createFooterPageNumPart(wordMLPackage, mp, factory);
    t.createFooterReference(wordMLPackage, mp, factory, relationship);
    t.saveWordPackage(wordMLPackage, new File("f:/saveFile/temp/s_simple.docx"));
}
Also used : ObjectFactory(org.docx4j.wml.ObjectFactory) MainDocumentPart(org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart) Relationship(org.docx4j.relationships.Relationship) WordprocessingMLPackage(org.docx4j.openpackaging.packages.WordprocessingMLPackage) File(java.io.File)

Example 4 with Relationship

use of org.docx4j.relationships.Relationship in project docx4j-template by vindell.

the class Docx4J_简单例子 method createHeaderPart.

// 图片页眉
public Relationship createHeaderPart(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory) 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));
    return rel;
}
Also used : Relationship(org.docx4j.relationships.Relationship) HeaderPart(org.docx4j.openpackaging.parts.WordprocessingML.HeaderPart)

Example 5 with Relationship

use of org.docx4j.relationships.Relationship in project docx4j-template by vindell.

the class Docx4J_简单例子2 method createTextFooterPart.

// 文字页脚
public Relationship createTextFooterPart(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory, String content, JcEnumeration jcEnumeration) throws Exception {
    FooterPart footerPart = new FooterPart();
    Relationship rel = t.addTargetPart(footerPart);
    footerPart.setJaxbElement(getTextFtr(wordprocessingMLPackage, factory, footerPart, content, jcEnumeration));
    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