当前位置: 首页>>代码示例>>Java>>正文


Java WordprocessingMLPackage.createPackage方法代码示例

本文整理汇总了Java中org.docx4j.openpackaging.packages.WordprocessingMLPackage.createPackage方法的典型用法代码示例。如果您正苦于以下问题:Java WordprocessingMLPackage.createPackage方法的具体用法?Java WordprocessingMLPackage.createPackage怎么用?Java WordprocessingMLPackage.createPackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.docx4j.openpackaging.packages.WordprocessingMLPackage的用法示例。


在下文中一共展示了WordprocessingMLPackage.createPackage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
/**
  *  跟前面的做的一样, 我们再一次创建了一个表格, 并添加了三个单元格, 其中有两个
  *  单元带有样式. 在新方法中我们传进表格行, 单元格内容, 是否为粗体及字体大小作
  *  为参数. 你需要注意, 因为the Office Open specification规范定义这个属性是半个
  *  点(half-point)大小, 因此字体大小需要是你想在Word中显示大小的两倍, 
 */
public static void main (String[] args) throws Docx4JException {
    wordMLPackage = WordprocessingMLPackage.createPackage();
    factory = Context.getWmlObjectFactory();
 
    Tbl table = factory.createTbl();
    Tr tableRow = factory.createTr();
 
    addRegularTableCell(tableRow, "Normal text");
    addStyledTableCell(tableRow, "Bold text", true, null);
    addStyledTableCell(tableRow, "Bold large text", true, "40");
 
    table.getContent().add(tableRow);
    addBorders(table);
 
    wordMLPackage.getMainDocumentPart().addObject(table);
    wordMLPackage.save(new java.io.File("src/main/files/HelloWord6.docx") );
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:24,代码来源:TableWithStyledContent.java

示例2: main

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    //创建一个word
    //读取可以使用WordprocessingMLPackage.load方法
    WordprocessingMLPackage word = WordprocessingMLPackage.createPackage();
    String imageFilePath = Docx4jTest.class.getResource("/lw.jpg").getPath();

    //创建页眉
    HeaderPart headerPart = createHeader(word);
    //页眉添加图片
    headerPart.getContent().add(newImage(word, headerPart, imageFilePath));

    //创建页脚
    FooterPart footerPart = createFooter(word);
    //添加图片
    footerPart.getContent().add(newImage(word, footerPart, imageFilePath));

    //主内容添加文本和图片
    word.getMainDocumentPart().getContent().add(newText("http://www.mybatis.tk"));
    word.getMainDocumentPart().getContent().add(newText("http://blog.csdn.net/isea533"));

    word.getMainDocumentPart().getContent().add(
            newImage(word, word.getMainDocumentPart(), imageFilePath));

    //保存
    word.save(new File("d:/1.docx"));
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:27,代码来源:Docx4jTest.java

示例3: main

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
/**
 *  First we create the package, then we alter the style sheet and add some
 *  styled paragraphs. Finally we save the package.
 */
public static void main (String[] args) throws Docx4JException {
    wordMLPackage = WordprocessingMLPackage.createPackage();
    alterStyleSheet();
 
    wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Title",
        "Hello World! This title is now in Arial.");
    wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Subtitle",
        "Subtitle, this subtitle is now Arial too");
    wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Heading1",
        "As is Heading1");
    wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Heading2",
        "Heading2 is now Arial, no longer bold and has an underline " +
        "and fontsize 12");
    wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Heading3",
        "Heading3 is now Arial");
    wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Normal",
        "And normal text has changed to Arial and fontsize 10");
 
    wordMLPackage.save(new java.io.File("src/main/files/HelloWord12.docx") );
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:25,代码来源:ChangingTheStyleSheet.java

示例4: main

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
/**
 *  创建一个带边框的表格并添加四个带内容的行, 然后将表格添加到文档并保存
 */
public static void main (String[] args) throws Docx4JException {
    wordMLPackage = WordprocessingMLPackage.createPackage();
    factory = Context.getWmlObjectFactory();
 
    Tbl table = factory.createTbl();
    addBorders(table);
 
    addTableRowWithMergedCells("Heading 1", "Heading 1.1",
        "Field 1", table);
    addTableRowWithMergedCells(null, "Heading 1.2", "Field 2", table);
 
    addTableRowWithMergedCells("Heading 2", "Heading 2.1",
        "Field 3", table);
    addTableRowWithMergedCells(null, "Heading 2.2", "Field 4", table);
 
    wordMLPackage.getMainDocumentPart().addObject(table);
    wordMLPackage.save(new java.io.File(
        "src/main/files/HelloWord9.docx") );
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:23,代码来源:TableWithMergedCells.java

示例5: testDocx4jCreateTable

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
public void testDocx4jCreateTable() throws Exception {  
    boolean landscape = false;  
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage  
            .createPackage(PageSizePaper.A4, landscape);  
    ObjectFactory factory = Context.getWmlObjectFactory();  
    setPageMargins(wordMLPackage, factory);  
    String imgFilePath = "f:/saveFile/tmp/2sql日志.jpg";  
    Tbl table = createTableWithContent(wordMLPackage, factory, imgFilePath);  
    wordMLPackage.getMainDocumentPart().addObject(table);  
    wordMLPackage.save(new File("f:/saveFile/temp/sys_"  
            + System.currentTimeMillis() + ".docx"));  
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:13,代码来源:Docx4j_创建表格_S5_Test.java

示例6: buildWhithDoc

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
public WordprocessingMLPackage buildWhithDoc(Document doc,boolean altChunk) throws IOException, Docx4JException {
/*	
 * 	根据docx4j.properties配置文件中:
 * 	docx4j.PageSize = A4
 * 	docx4j.PageOrientationLandscape = true
 * 	创建默认的WordProcessingML package
 */
      WordprocessingMLPackage wmlPackage = WordprocessingMLPackage.createPackage();
      //返回WordprocessingMLPackage对象
      return buildWhithDoc(wmlPackage , doc, altChunk);
  }
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:12,代码来源:WordprocessingMLPackageBuilder.java

示例7: buildWhithHtml

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
/**
 * 将 {@link org.jsoup.nodes.Document} 对象转为 {@link org.docx4j.openpackaging.packages.WordprocessingMLPackage}
 * @param htmlFile
 */
public WordprocessingMLPackage buildWhithHtml(File htmlFile,boolean altChunk) throws IOException, Docx4JException {
	/*	
	 * 	根据docx4j.properties配置文件中:
	 * 	docx4j.PageSize = A4
	 * 	docx4j.PageOrientationLandscape = true
	 * 	创建默认的WordProcessingML package
	 */
	WordprocessingMLPackage wmlPackage = WordprocessingMLPackage.createPackage();
	//返回WordprocessingMLPackage对象
	return buildWhithHtml(wmlPackage,htmlFile, altChunk);
   }
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:16,代码来源:WordprocessingMLPackageBuilder.java

示例8: main

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
/**
 *  首先我们创建对象工厂和包并从包中抽出文档部件. 然后我们添加目录表, 后面跟着一些带有分类
 *  标题样式的段落. 最后我们保存包.
 */
public static void main(String[] args) throws Docx4JException {
    factory = Context.getWmlObjectFactory();
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
    MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
 
    addTableOfContent(documentPart);
 
    documentPart.addStyledParagraphOfText("Heading1", "Hello 1");
    documentPart.addStyledParagraphOfText("Heading2", "Hello 2");
    documentPart.addStyledParagraphOfText("Heading3", "Hello 3");
    documentPart.addStyledParagraphOfText("Heading1", "Hello 1");
 
    wordMLPackage.save(new File("src/main/files/HelloWord10.docx"));
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:19,代码来源:AddingTableOfContent.java

示例9: main

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
public static void main (String[] args) throws Docx4JException {
    wordMLPackage = WordprocessingMLPackage.createPackage();
    factory = Context.getWmlObjectFactory();
 
    Tbl table = createTableWithContent();
 
    addBorders(table);
 
    wordMLPackage.getMainDocumentPart().addObject(table);
    wordMLPackage.save(new java.io.File(
        "src/main/files/HelloWord5.docx") );
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:13,代码来源:TableWithBorders.java

示例10: main

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
public static void main (String[] args) throws Docx4JException {
    wordMLPackage = WordprocessingMLPackage.createPackage();
    factory = Context.getWmlObjectFactory();
 
    wordMLPackage.getMainDocumentPart().addParagraphOfText("Hello Word!");
 
    addPageBreak();
 
    wordMLPackage.getMainDocumentPart().addParagraphOfText("This is page 2!");
    wordMLPackage.save(new java.io.File("src/main/files/HelloWord11.docx") );
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:12,代码来源:AddingAPageBreak.java

示例11: WordprocessingMLPackageRender

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
public WordprocessingMLPackageRender() throws Docx4JException{
	this(WordprocessingMLPackage.createPackage());
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:4,代码来源:WordprocessingMLPackageRender.java

示例12: createWordprocessingMLPackage

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
public WordprocessingMLPackage createWordprocessingMLPackage()  
        throws Exception {  
    return WordprocessingMLPackage.createPackage();  
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:5,代码来源:Docx4j_创建批注_S3_Test.java

示例13: main

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
/**
 *  First we create the package and the factory. Then we create the footer.
 *  Finally we add two pages with text to the document and save it.
 */
public static void main (String[] args) throws Exception {
    
	wordMLPackage = WordprocessingMLPackage.createPackage();
    factory = Context.getWmlObjectFactory();
 
    Relationship relationship = createFooterPart();
    createFooterReference(relationship);
 
    MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
 
    documentPart.addParagraphOfText("Hello World!");
 
    addPageBreak(documentPart);
 
    documentPart.addParagraphOfText("This is page 2!");
    wordMLPackage.save(new File("src/main/files/HelloWord15.docx") );
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:22,代码来源:AddingPageNrToFooter.java

示例14: createWordprocessingMLPackage

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
public WordprocessingMLPackage createWordprocessingMLPackage()
		throws Exception {
	return WordprocessingMLPackage.createPackage();
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:5,代码来源:Docx4J_简单例子.java

示例15: main

import org.docx4j.openpackaging.packages.WordprocessingMLPackage; //导入方法依赖的package包/类
public static void main(String[] args) throws Docx4JException {
	wordMLPackage = WordprocessingMLPackage.createPackage();
	factory = Context.getWmlObjectFactory();

	Tbl table = factory.createTbl();
	Tr tableRow = factory.createTr();

	addTableCell(tableRow, "Field 1");
	addTableCell(tableRow, "Field 2");

	table.getContent().add(tableRow);

	wordMLPackage.getMainDocumentPart().addObject(table);

	wordMLPackage.save(new java.io.File("src/main/files/HelloWord4.docx"));
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:17,代码来源:AddingATable.java


注:本文中的org.docx4j.openpackaging.packages.WordprocessingMLPackage.createPackage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。