Carrying over embedded packages from word to pdf

Hi,

I have a word document and i am adding an image to it by embedding the image in the form of a package. But when the corresponding pdf for that word is generated the embedded package containing the image is carried over as an attachment but i am not able to open it.

Here is the code that i have written for converting the embedded files:

switch (shape.OleFormat.ProgId)
{
    // WordPad.Document.1 .rtf Visio.Drawing.11:.vsd
    case "Excel.Sheet.8":
        ext = "xls";
        filenameembed = shape.OleFormat.IconCaption;
        break;
    case "Excel.Sheet.12":
        ext = "xlsx";
        filenameembed = shape.OleFormat.IconCaption;
        break;
    case "AcroExch.Document.7":
        ext = "pdf";
        filenameembed = shape.OleFormat.IconCaption;
        break;
    case "Word.Document.8":
        ext = "doc";
        filenameembed = shape.OleFormat.IconCaption;
        break;
    case "Word.Document.12":
        ext = "docx";
        filenameembed = shape.OleFormat.IconCaption;
        break;
    case "WordPad.Document.1":
        ext = "rtf";
        filenameembed = shape.OleFormat.IconCaption;
        break;
    case "Visio.Drawing.11":
        ext = "vsd";
        filenameembed = shape.OleFormat.IconCaption;
        break;
    default:
        ext = "jpg";
        filenameembed = shape.OleFormat.IconCaption;
        break;
}

The ProgId for the embedded package containing the image is “Package” but since i don’t have any case for handling that, by default the ext is set as “jpg”. And therefore the file is not opening in pdf as it there is a conversion conflict (i.e., embedded package containing image is not getting converted to jpg).

Can you please suggest the extension to which the embedded package containing the image should be converted or any other solution to the problem?

PS:- When accessing the embedded package’s property in word it is showing as JPEG therefore i had set the conversion ext as jpg.

Hi,

Thank you for contacting support. Please provide us your source Word document and complete code. It’ll help us to replicate the issue on our side. You can create a zip archive of the required files and attach to your forum reply.

Hi i have attached the word document.

I cant share the entire code. The problem is, in the code that i have shared, when the embedded files are retrieved from the word document in the below line-

filenameembed = shape.OleFormat.IconCaption;

the extensions are not getting retrieved. So they are not opening , even though they are present in the attachment section of the pdf. For some files the extensions are retrieved, but for the embedded files present in the document that i have shared they are not retrieved.

I also read the content of the below link -

Link to embedded files

But i could not understand how to implement it. I want the same functionality as the user has mentioned in the above link. Please tell me how to do it using the “shape.OleFormat.ProgId” way.

Hi,

pratyushmaharana899:

filenameembed = shape.OleFormat.IconCaption;

Please use the OleFormat.SuggestedFileName and OleFormat.SuggestedExtension properties to get the correct file name.

[.NET, C#]

// load a Word document

var wordDoc = new Aspose.Words.Document(@"C:\AD\test875\Sample.docx");
// iterate through shapes
foreach (Shape shape in wordDoc.GetChildNodes(NodeType.Shape, true))
Console.WriteLine(shape.OleFormat.SuggestedFileName + shape.OleFormat.SuggestedExtension); 

Please let us know in case of any confusion or questions.

Hi,

I solved the problem for now by adding the file extensions to the file name before saving them. But is there any other way to achieve the functionality of opening the files on clicking the icons (as it happens in the word document) other than that mentioned in the below link

“aspose.comhttps://forum.aspose.com/t/63084”.

Or a detailed description of the method, to achieve the functionality, that has been shown in the link.

Hi,

Thank you for being patient. We’re working over your query and will get back to you soon.

Hi,

I didn’t get any update regarding my query.

Thanks and Regards,

Pratyush Maharana

Hi Pratyush,

We’re sorry for not getting back to you soon. We’ve created another forum thread in the Aspose.Pdf forum. One of our fellow workers will reply you soon there. We have also intimated Aspose.Pdf team. Please spare us a little time.

Forum thread: https://www.aspose.com/community/forums/817903/opening-the-files-on-clicking-the-icons/showthread.aspx#817903

pratyushmaharana899:

Hi,

I solved the problem for now by adding the file extensions to the file name before saving them. But is there any other way to achieve the functionality of opening the files on clicking the icons (as it happens in the word document) other than that mentioned in the below link

https://forum.aspose.com/t/link-to-embedded-files/63084 separate thread. Should you have any further query, please feel free to contact.