70174917

Date: 2021-11-30 19:27:06
Score: 4.5
Natty:
Report link

I solve it like that but it is just run for word document any suggestion how can i use it to merge with pdf excel and picture ?

 public void mergeDocx(InputStream s1, InputStream s2, OutputStream os) throws Exception {
        WordprocessingMLPackage target = WordprocessingMLPackage.load(s1);
        insertDocx(target.getMainDocumentPart(), IOUtils.toByteArray(s2));
        SaveToZipFile saver = new SaveToZipFile(target);
        saver.save(os);
    }
    private static void insertDocx(MainDocumentPart main, byte[] bytes) throws Exception {
        AlternativeFormatInputPart afiPart = new AlternativeFormatInputPart(new PartName("/part" + (chunk) + ".docx"));
        afiPart.setContentType(new ContentType(CONTENT_TYPE));
        afiPart.setBinaryData(bytes);
        Relationship altChunkRel = main.addTargetPart(afiPart);
        CTAltChunk chunk = Context.getWmlObjectFactory().createCTAltChunk();
        chunk.setId(altChunkRel.getId());
        main.getContent().add(1,chunk); 
// i add this method 
    ```


Reasons:
  • Blacklisted phrase (1.5): how can i
  • RegEx Blacklisted phrase (1): any suggestion
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Nancy Al Housseiny