How to insert Pdf Document into word document?

How to insert Pdf Document into word document

@jai25 Unfortunately, loading PDF document is not supported in Java version of Aspose.Words. This feature is supported only in .NET and Python version.
If you would like to insert content of PDF document into Word document, you can first convert PDF to Word document using Aspose.PDf for java and then insert the resulting document into the Word document using Aspose.Words:
https://docs.aspose.com/words/java/insert-and-append-documents/

If you would like to insert the PDF document as an embedded object, you can use the approach described here:
https://docs.aspose.com/words/java/working-with-ole-objects/

FYI @eduardo.canal

1 Like

@alexey.noskov Could you please add some sample code to insert PDF document as an embedded object into word document.

Thank You

@jai25 You can use the following simple code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertOleObject("C:\\Temp\\in.pdf", false, true, null);
doc.save("C:\\Temp\\out.docx");

@alexey.noskov I tried your code but Iā€™m getting this icon in word image.png (2.5 KB)

@jai25 Yes, this is the expected output of the provided code. Could you please clarify what is your expected output?

I need PDF content should print on the word document

@jai25 In this case you should use Aspose.PDF to read content from PDF document or convert it to Word document and then use Aspose.Words to insert this content into MS Word document. See the first option in my initial answer.

Could please add sample code to convert pdf doc to word doc and then inserting word document to MS word document.

@jai25 Please Aspose.PDF documentation to learn how to convert PDF to Word document and then you can insert the resulting document into the Word document using Aspose.Words. See our documentation to learn how to achieve this:
https://docs.aspose.com/words/java/insert-and-append-documents/

I have access to only aspose word. Is Asopose.PDF will work?

@jai25 Aspose.PDF is a separate, so you need another license for it.