use of org.docx4j.template.io.WordprocessingMLPackageRender in project docx4j-template by vindell.
the class AddingAFooter method main.
/**
* First we create the package and the factory. Then we create the footer part,
* which returns a relationship. This relationship is then used to create
* a reference. Finally we add some text to the document and save it.
*/
public static void main(String[] args) throws Docx4JException {
WordprocessingMLPackageRender render = new WordprocessingMLPackageRender(wordMLPackage);
wordMLPackage = WordprocessingMLPackage.createPackage();
factory = Context.getWmlObjectFactory();
Relationship relationship = createFooterPart();
createFooterReference(relationship);
wordMLPackage.getMainDocumentPart().addParagraphOfText("Hello Word!");
wordMLPackage.save(new File("d://HelloWord14.docx"));
}
use of org.docx4j.template.io.WordprocessingMLPackageRender in project docx4j-template by vindell.
the class AddingAnInlineImageTest method main.
/**
* 像往常一样, 我们创建了一个包(package)来容纳文档.
* 然后我们创建了一个指向将要添加到文档的图片的文件对象.为了能够对图片做一些操作, 我们将它转换
* 为字节数组. 最后我们将图片添加到包中并保存这个包(package).
*/
public static void main(String[] args) throws Exception {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
File file = new File("src/main/resources/iProfsLogo.png");
byte[] bytes = WMLPackageUtils.imageToByteArray(file);
WordprocessingMLPackageRender render = new WordprocessingMLPackageRender(wordMLPackage);
render.addImageToPackage(bytes);
wordMLPackage.save(new java.io.File("src/main/files/HelloWord7.docx"));
}
Aggregations