检查Word文档中是否存在特定图像 [英] Check whether a particular image is present in a Word document
问题描述
大家好,
我们有一个项目要求,我们需要检查Word/Excel文档中是否存在特定图像.
注意:如果完全有图像存在,它将出现在文档末尾.
例如,我们有一个Word文档(Word.docx)和一个图像(Image1.jpg).我需要检查Word文档"Word.docx"是否最后包含图像"Image1.jpg".
请注意,我正在使用编程语言C#
我在相当长的一段时间内都在为这个问题而苦苦挣扎.我找不到来自互联网的适当帮助.
任何人都可以帮助我实现这一目标吗?
在此先感谢,
Kishor Reddy
使用Interop, ^ ]应该包含图片,因此,如果您在其中循环浏览,则应该找到图片.使用InlineShapes的blockquote>
,我得到了word文档的最后一个图像.并比较了两个图像(word文档的最后一个图像和另一个图像)的像素.
步骤:
1.使用InlineShapes获取文档的最后一张图像
2.转换为位图.
3.转换自定义图像的每个像素.
4.如果所有像素均相等,则两个图像都相同.
有时,基于Word属性,边框会添加到嵌入的图像中.在比较像素时,我们需要忽略与边框相关的像素.
谢谢....
Hi All,
We have a project requirement that we need to check whether a particular image is present in a Word/Excel document.
Note: If at all the image is present, it will be present at the end of document.
For example, we have a word document (Word.docx) and an image (Image1.jpg). I need to check whether the Word document "Word.docx" contains the image "Image1.jpg" at the end.
Please note that i am using programming language C#
I am struggling with this issue from quite some time. I could not find appropriate help from internet.
Can anyone help me acheiving this ?
Thanks in Advance,
Kishor Reddy解决方案Using Interop, the InlineShapes[^] of the document should contain the pictures so if you loop through that, you should find the pictures.
using InlineShapes, i got the last image of the word document. and compared the pixels of both the images (the last image of the word document and the other image).
Steps:
1. Get the last image of the document using InlineShapes
2. Convert to bitmap.
3. Convert each pixel of the custom image.
4. If all the pixels are equal, then both the images are same.
Sometimes, based on the Word properties, borders are added to the embedded image. While comparing the pixels, we need to ignore the pixels related to the borders.
thanks....
这篇关于检查Word文档中是否存在特定图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!