简体   繁体   English

我可以使用OpenXML SDK在Word文档中找到文本的位置吗?

[英]Can I find the location of text in a Word document using OpenXML SDK?

I would like to put some known text in a Word doc and programmatically find it's x,y location with respect to the document or page using .NET. 我想在Word文档中放入一些已知文本,并使用.NET以编程方式找到它相对于文档或页面的x,y位置。 Is that possible? 那可能吗? I was looking at using the OpenXML SDK but I don't see a path to getting that to work. 我正在考虑使用OpenXML SDK,但我没有看到让它工作的途径。 Or could I use something like an image or bookmark to do this? 或者我可以使用像图像或书签这样的东西来做到这一点?

Ultimately I'm trying to save the Word doc as a PDF or image (using a library like Aspose) and overlay some content at that location. 最终我试图将Word文档保存为PDF或图像(使用像Aspose这样的库)并在该位置覆盖一些内容。 Any ideas are appreciated. 任何想法都表示赞赏。

This is an old question but I think it's helpful to point out this. 这是一个老问题,但我认为指出这一点很有帮助。

A solution is to put a placeholder text, find it it the document, replace it with an image and save. 解决方案是放置占位符文本,将其作为文档找到,将其替换为图像并保存。

This is explained in detail in this answer 这个答案中详细解释了这一点

Based on further research and general understanding of the XML structure of the docs, it doesn't look like this is possible. 基于对文档的XML结构的进一步研究和一般理解,它看起来不可能。 I looked at the third party components from Aspose to see if they supported it and they don't from a Word doc, but it may be possible from a PDF. 我查看了Aspose的第三方组件,看看他们是否支持它,而不是来自Word文档,但它可能来自PDF。 So I thought I'd post a link to that info: http://www.aspose.com/community/forums/thread/420805.aspx 所以我想我会发布一个指向该信息的链接: http//www.aspose.com/community/forums/thread/420805.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM