We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Embed zip-text-pdf or any format in Word document using java

How can I Embed zip,text,pdf or any format in Word document using Aspose.Words for JAVA.

Hi there,

Thanks for your inquiry. Yes, you can insert word/pdf/text files in word document at any place. Please use DocumentBuilder.insertOleObject method to insert an embedded or linked OLE object from a file into the document.

Please check following code example for your kind reference. Hope this helps you.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
BufferedImage image = ImageIO.read(new File(MyDir + "Aspose.Words.png"));
Shape oleObject = builder.insertOleObject(MyDir + "ActualOutput.docx", true, false, image);
doc.save(MyDir + "out.docx");

Is it possible to embed zip as well as that didn’t work for me.

Hi there,

Thanks for your inquiry. Yes, you can embed zip file in Word document using DocumentBuilder.insertOleObject. Could you please share your scenario along with documents in which this method does not work at your side? I will investigate the issue on my side and provide you more information.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertOleObject(MyDir + "in.zip", false, false, null);
doc.save(MyDir + "Out.docx");

hi

i could not find in which jar file DocumentBuilder.insertOleobject method is present.
can you please help me out of this

thanks

Hi there,

Thanks for your inquiry. Please use latest version of Aspose.Words for Java 16.1.0 and let us know if you have any more queries.

Under which jar file will i get the method “builder.insertOleObject” ?

I have used aspose-words-16.12.0-jdk16.jar and also
aspose.words.jdk16-7.0.0.jar

Hi there,

Thanks for your inquiry. It seems that you are using older Jar file of Aspose.Words. The latest version of Aspose.Words for Java contains the DocumentBuilder.InsertOleObject method. Please remove all Aspose.Words Jar files from your application and include the latest Jar file.