use of org.docx4j.openpackaging.io3.stores.UnzippedPartStore in project docx4j-template by vindell.
the class Word_解压_Unzip_S3_Test method zipXml.
public void zipXml(String inputfilepath, String outFilePath) throws Exception {
System.out.println(inputfilepath);
// Load the docx
File baseDir = new File(inputfilepath);
UnzippedPartStore partLoader = new UnzippedPartStore(baseDir);
final Load3 loader = new Load3(partLoader);
OpcPackage opc = loader.get();
// Save it zipped
ZipPartStore zps = new ZipPartStore();
zps.setSourcePartStore(opc.getSourcePartStore());
Save saver = new Save(opc, zps);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(new File(outFilePath));
saver.save(fos);
} catch (FileNotFoundException e) {
throw new Docx4JException("Couldn't save " + outFilePath, e);
} finally {
IOUtils.closeQuietly(fos);
}
}
use of org.docx4j.openpackaging.io3.stores.UnzippedPartStore in project docx4j-template by vindell.
the class Word_解压_Unzip_S3_Test2 method unzipWord.
public void unzipWord(String fileName, String outFilePath) throws Exception {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(fileName));
File baseDir = new File(outFilePath);
baseDir.mkdir();
UnzippedPartStore ups = new UnzippedPartStore(baseDir);
ups.setSourcePartStore(wordMLPackage.getSourcePartStore());
Save saver = new Save(wordMLPackage, ups);
saver.save(null);
}
use of org.docx4j.openpackaging.io3.stores.UnzippedPartStore in project docx4j-template by vindell.
the class Word_解压_Unzip_S3_Test method unzipWord.
public void unzipWord(String fileName, String outFilePath) throws Exception {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(fileName));
File baseDir = new File(outFilePath);
baseDir.mkdir();
UnzippedPartStore ups = new UnzippedPartStore(baseDir);
ups.setSourcePartStore(wordMLPackage.getSourcePartStore());
Save saver = new Save(wordMLPackage, ups);
saver.save(null);
}
use of org.docx4j.openpackaging.io3.stores.UnzippedPartStore in project docx4j-template by vindell.
the class Word_解压_Unzip_S3_Test2 method zipXml.
public void zipXml(String inputfilepath, String outFilePath) throws Exception {
System.out.println(inputfilepath);
// Load the docx
File baseDir = new File(inputfilepath);
UnzippedPartStore partLoader = new UnzippedPartStore(baseDir);
final Load3 loader = new Load3(partLoader);
OpcPackage opc = loader.get();
// Save it zipped
ZipPartStore zps = new ZipPartStore();
zps.setSourcePartStore(opc.getSourcePartStore());
Save saver = new Save(opc, zps);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(new File(outFilePath));
saver.save(fos);
} catch (FileNotFoundException e) {
throw new Docx4JException("Couldn't save " + outFilePath, e);
} finally {
IOUtils.closeQuietly(fos);
}
}
Aggregations