try { Docx4J.save(wordMLPackage, tmpDocxFile, Docx4J.FLAG_SAVE_ZIP_FILE); } catch (Exception e) { throw new TocException("Error saving pkg as tmp file; " + e.getMessage(),e);
save(wmlPackage, baos);
Docx4J.save(tmpMergeResult, outStream);
/** * 保存当前Docx文件 */ private static void saveDocx(WordprocessingMLPackage wordMLPackage, String savePath) throws FileNotFoundException, Docx4JException { Docx4J.save(wordMLPackage, new File(savePath), Docx4J.FLAG_SAVE_ZIP_FILE); }
try { Docx4J.save(wordMLPackage, tmpDocxFile, Docx4J.FLAG_SAVE_ZIP_FILE); } catch (Exception e) { throw new TocException("Error saving pkg as tmp file; " + e.getMessage(),e);
save(wmlPackage, baos);
/** * 传入一个 word 文件,和一个水印文件,给这个 word文件加水印 * @author eko.zhan at 2018年9月17日 上午11:09:56 * @param file * @param imgFile * @throws Docx4JException * @throws JAXBException * @throws IOException */ public void process() throws WatermarkException { try { WordprocessingMLPackage wordMLPackage = Docx4J.load(file); this.wordMLPackage = wordMLPackage; SectPr sectPr = createSectPr(); wordMLPackage.getMainDocumentPart().getContents().getBody().setSectPr(sectPr); Docx4J.save(wordMLPackage, file); } catch (Docx4JException e) { throw new WatermarkException("Docx4JException", e); } catch (JAXBException e) { throw new WatermarkException("JAXBException", e); } catch (IOException e) { throw new WatermarkException("IOException", e); } }
Docx4J.save(tmpMergeResult, outStream);