将文件插入/嵌入到 DOCX 文件 - 确定文件类型
假设我有一个 API,它允许客户端将文件插入到 DOCX 模板中,它们只需传递文件的路径即可。如果它是一个图像,我只想将图像添加到文件中,如果它是生活 RTF/DOC,那么我可以嵌入它,以便内容可见,如果它是其他类型,如 MP3 或 PDF,那么它可能只是嵌入一个图标。
我想我可以简单地查看文件扩展名,但即便如此,我认为我可能需要正确的文件类型字符串,我看到类似 mainPart.AddEmbeddedObjectPart("application/vnd.openxmlformats-officedocument.oleObject")< 的代码片段/code> 并想知道如何将文件扩展名映射到类型。有没有一个方便的页面包含这些内容?
而且,我认为我确实需要针对图片/其他类型的不同逻辑?嵌入图片会不会很奇怪?
Let's say I have an API which lets clients insert a file into a DOCX template, they just pass a path to the file. If it's an image I just want to add an image to the file, if it's something life RTF/DOC then I can maybe embed it so the content is visible, if it's some other type like MP3 or PDF then it might simply embed with an icon.
I guess I could simply look at file extension, but even then I think I might need the correct file-type string, I see code snippets like mainPart.AddEmbeddedObjectPart("application/vnd.openxmlformats-officedocument.oleObject")
and wonder how I can map file-extension to type. Is there a handy page with such things?
And, I assume I do need different logic for pictures/other types? It would be weird to embed a picture?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论