开发者

Embed a WPF UI object into a Word/OpenOffice document?

I'm working on a project which needs to embed custom objects into documents (either Microsoft Word or OpenOffice Writer). The objects would essentially be like Microsoft Equation or OpenOffice Formula objects, except they would render and allow editing of content specific to our business. Ultimately, the documents are exported into PDF.

Since everything else in this project is based on WPF and our development environments and build processes are based on .Net, it would be nice to be able to create these objects using exclusively or almost exclusively WPF/.Net.

The most obvious choice for embedding objects into documents is OLE, but as far as I can tell, WPF 开发者_运维技巧has very little support for OLE.

What options do I have? What's the best (reliable, performant, and simple) do this?

(Or if anyone knows for sure that there isn't a good way other than going to OLE with a language like C++ or VB6, that would be good to know too)


You can do that inside a WPF RichTextBox, just insert an InlineUIContainer (or BlockUIContainer) where can put any UIElement like a button or anything more complicated.

You can then convert the RichTextBox content, orginally a FlowDocument, into RTF or XAML or HTML, or to the Office OpenXML format (.docx) with the OpenXML SDK.

Maybe it's possible to replace the RichTexBox with an actual Microsoft Word window, stuck inside your WPF application, and embed WPF controls in it just like you do with a InlineUIContainer, but I don't know how yet. I'll post if I find out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜