Hello all, i have solved problem for embedding txt ole objects to word(using POI). It should be similar for PDFs.
this is procedure: 1.create template word document with embedded empty file in word. 2.use http://apache-poi.1045710.n5.nabble.com/file/n4770470/Ole10Native.java Ole10Native.java . It is edited class from POIs Ole10Native. 3. in code use: final PackagePart packagePart = document.getAllEmbedds().get(0);//document is XWPFDocument final POIFSFileSystem fs = new POIFSFileSystem(packagePart.getInputStream()); final Ole10Native ole = Ole10Native.createFromEmbeddedOleObject(fs);//before mentioned Ole10Native class Entry entry = fs.getRoot().getEntry(Ole10Native.OLE10_NATIVE); //Deletes old ole entry.delete(); //creates new content byte[] newContent = "New Content of embedded ole object".getBytes(); //Creates new ole fs.getRoot().createDocument(Ole10Native.OLE10_NATIVE, new ByteArrayInputStream(ole.getOutputStream(newContent).toByteArray())); ByteArrayOutputStream stream = new ByteArrayOutputStream(); fs.writeFilesystem(stream); //Save package part OutputStream os3 = packagePart.getOutputStream(); try{ os3.write(stream.toByteArray()); os3.flush(); } finally { os3.close(); } 4. save document to some file Note: this just changes content of embedded file. Does not affect e.g. name of icon displayed in word as embedded file -- View this message in context: http://apache-poi.1045710.n5.nabble.com/Can-POIFS-convert-PDF-to-OLE-tp2304362p4770470.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
