Insert / Insert File into DOCX File - File Type Definition

Say I have an API that allows clients to embed a file in a DOCX template, they just pass the file path. If this is an image, I just want to add the image to the file, if it is something RTF / DOC vital, then I can embed it so that the content is visible, if it is some other type, such as MP3 or PDF, then it can just insert using icon.

I think I could just look at the file extension, but even then I think that I may need the correct line of the file type, I see code snippets such as mainPart.AddEmbeddedObjectPart("application/vnd.openxmlformats-officedocument.oleObject"), and I wonder how I can match the file extension for input. Is there a convenient page with such things?

And I suppose I need a different logic for images / other types? Would it be strange to insert a picture?

+3
source share

Source: https://habr.com/ru/post/1757351/


All Articles