How to insert a PDF into a Word document

I’ve seen how to insert a word document into another word document:
https://docs.aspose.com/words/java/insert-and-append-documents/

Hi, is it possible to insert a pdf document into a word document, using a similar way?

Thanks

Hi Alessandro,

Thanks for your query. I regret to share with you that Aspose.Words does not support the requested feature.

Hi
Thanks for your request. The latest version of Aspose.Pdf supports converting PDF documents to DOC format. So you can use Aspose.Pdf to convert your PDFs to DOC and then use Aspose.Words to insert the generated DOC field into another Word document.
Best regards,

Hi, thank you for your support.
I tried to convert the pdf document do word, and then to add this to my destination word document.
But the conversion has some problems.
I readed the post:
https://docs.aspose.com/words/net/convert-pdf-to-other-document-formats/

And I’ve tried a sample code to check the conversion. See this code:

Dim pdfDocument As Aspose.Pdf.Document = New Aspose.Pdf.Document("c:\tmp\example.pdf")
pdfDocument.Save("c:\tmp\output.doc", Aspose.Pdf.SaveFormat.Doc)
Dim docDocument As Aspose.Words.Document = New Aspose.Words.Document("c:\tmp\output.doc")

But
this code does work well.
The output document file will be generated, but
when I try to load the file in Aspose.Words.Document object I obtain an
exception:

“The document appears to be corrupted and cannot be loaded.”

Another problem is that the Save method of the pdf document object writes many debug messages on the console (my sample code is inside a console application).

Is there some error on my code?

Otherwise, some workaround are avalaible?

Hi Alessandro,

I have tested the same scenario at my end and have successfully converted the PDF file to Doc. I have successfully loaded the generated doc file with Aspose.Words. Please see the code below and find the generated doc file in attachment.

Please use the latest version of Aspose.Words for .NET 10.8.0 and latest version of Aspose.Pdf for .NET 6.5.0.

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(MyDir + "example.pdf");
pdfDocument.Save(MyDir + "AsposeOut.doc", Aspose.Pdf.SaveFormat.Doc);
Aspose.Words.Document doc = new Aspose.Words.Document(MyDir + "AsposeOut.doc");

Hi there,

I used the code you mentioned above and it does help to attach the the documents but the problem is output file lost all formatting. I tried both lines (one by one) of following code and the output file is messed up.

builder.InsertDocument(attachment, ImportFormatMode.KeepSourceFormatting);
PDFHelper.AppendAttachment(builder, attachment);

Please help.

Regards

Yas

Hi Yas,
Can you please share your input documents (Word and PDF) that you are combining and also share your complete code to reproduce the issue?
Best Regards,