Preserving Embedded PDFs from source Word Document while converting it to PDF as Destination File

Hello Team,

I have a requirement where I have Word Documents consisting of Embedded Files (PDFs) which needs be converted to PDF. The problem is when using the native MS-Word “Save As → PDF” option, the document is getting converted to PDF. But the embedded files in source Word document is missing from the output PDF(only thumbnail image, non-clickable/openable).

Could you please let us know if this issue could be resolved via any of your products.

Please note that this is needed for Word Documents located on Sharepoint Online.

Thanks.
Ankayjay.

@Ankayjay

To preserve embedded PDFs from a Word document when converting it to a PDF using Aspose.Words, you can utilize the PdfSaveOptions class. This class provides various options for saving documents in PDF format, including the handling of embedded objects.

Here’s a basic example of how to set up the conversion:

using Aspose.Words;
using Aspose.Words.Saving;

class Program
{
    static void Main()
    {
        // Load the Word document
        Document doc = new Document("path/to/your/document.docx");

        // Create PdfSaveOptions and set the necessary options
        PdfSaveOptions saveOptions = new PdfSaveOptions
        {
            // Ensure that embedded objects are preserved
            EmbedFullFonts = true, // This is just an example; adjust as needed
            // You can set other options as required
        };

        // Save the document as PDF
        doc.Save("path/to/output/document.pdf", saveOptions);
    }
}

In this example, the EmbedFullFonts option is set to true, which ensures that all fonts are embedded in the PDF. While this does not directly address the preservation of embedded PDFs, it is important to ensure that all content is properly handled during the conversion process.

Unfortunately, the Aspose.Words library does not explicitly mention the preservation of embedded files like PDFs in the documentation. However, it is designed to handle various types of embedded objects, so it may work as expected in your case.

If you encounter issues where embedded PDFs are still not clickable or openable, consider checking the version of Aspose.Words you are using, as updates may include improvements in handling embedded objects. Additionally, you may want to explore the documentation for any specific settings related to embedded objects.

For documents located on SharePoint Online, ensure that you have the necessary permissions and that the file paths are correctly set up to access the documents.

If you need further assistance or specific examples, feel free to ask!

Sources:
[1]: Working with PdfSaveOptions.cs

@Ankayjay You can use PdfSaveOptions.EmbedAttachments property to export embed attachments to the PDF document.

Thanks. Could you please share github link for sample code in Java & Python for converting Word Doc with Embedded PDF files (let’s call it source file) where the “Source” Word Doc should be converted to a Output PDF (let’s call it destination file).

The destination PDF file should retain the embedded docs from source Word file.

hanks. Could you please share github link for sample code in Java & Python for converting Word Doc with Embedded PDF files (let’s call it source file) where the “Source” Word Doc should be converted to a Output PDF (let’s call it destination file).

The destination PDF file should retain the embedded docs from source Word file.

@Ankayjay You can find code Aspose.Words code examples here for Java:
https://github.com/aspose-words/Aspose.Words-for-Java/
and for Python:
https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET/

Also, you can find code examples in our documentation and API References:
https://reference.aspose.com/words/python-net/aspose.words.saving/pdfsaveoptions/embed_attachments/

1 Like

Thanks for the solution !!

Even after successfully converting my Word to PDF format, the embedded PDFs & Links within the converted PDF file is not opening on Android Mobiles.

The embedded PDF File icon is just showing up as a “non-clickable” label image even after using Adobe acrobat Reader Android App.

But the same Word-to PDF converted document is viewed on Windows desktop, the embedded PDF is opening up seamlessly.

Is there any solution where embedded files within root PDF are ‘clickable & openable’ on an Android Mobile Device

@Ankayjay Probably PDF document viewer on Android device simply does not support embedded objects.

1 Like

Thank you Alexey, but curious to know if there is any workaround to make this work on mobile devices

@Ankayjay I am afraid, this is out of Aspose.Words scope. I think you should contact the PDF document viewer’s vendor.

1 Like