如何使用 C# 或更好的方式通过 VS.NET Automation 将文件打印到 XpsDocumentWriter?
我想要完成的任务(手动方式)
在 VS 2010 中,我的项目项是sequencediagrams,它们实际上只是 .xml 并具有 .sequencediagrams 后缀。所以我在 VS 中打开图表并转到 File->Print 。现在,我不在下拉列表中选择物理打印机,而是将其更改为 Microsoft XPS Document Writer,因为我想要输出 .XPS 文件。
代码中怎么做?
我正在尝试在 C# 代码中执行此操作,特别是在 VS 加载项(自动化)中。所以我拥有的是一个projectinfo的句柄,它给了我文件的完整路径,但我有点迷失在它的打印部分中。我想我可以使用 http://msdn.microsoft。 com/en-us/library/system.windows.xps.xpsdocumentwriter.aspx ,但方法签名似乎没有采用简单的文档路径。
有人有这方面的经验吗?建议?谢谢。
What I am trying to accomplish (the manual way)
In VS 2010, I have project items that are sequencediagrams, they are really just .xml and have a suffix of .sequencediagrams . So I open the diagram in VS and go to File->Print . Now I do not select a physical printer in the dropdown, I change that to Microsoft XPS Document Writer, because I want an outputed .XPS file.
How to do in code ?
I am trying to do this in C# code, specifically in a VS add-in (automation). So what I have is a handle to a projectinfo, which gives me the full path of the file, but I am kind lost in the print part of it. I thought I could use http://msdn.microsoft.com/en-us/library/system.windows.xps.xpsdocumentwriter.aspx , but the method signatures don't seem to take a simple document path.
Anyone have experience in this? suggestions? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
建议查看以下链接:
http://blogs.msdn.com/b/camerons/archive/2010/03/08/save-a-diagram-to-image-file.aspx
http://weblogs.asp. asp.net/gunnarpeipman/archive/2010/09/03/visual-studio-extension-save-uml-diagram-as-image.aspx
作者:Ryan Molden (MSFT)
感谢 Ryan,绕过了整个图表 - > XPS 步骤很棒。
It was suggested to look at these links:
http://blogs.msdn.com/b/camerons/archive/2010/03/08/save-a-diagram-to-image-file.aspx
http://weblogs.asp.net/gunnarpeipman/archive/2010/09/03/visual-studio-extension-save-uml-diagram-as-image.aspx
by Ryan Molden (MSFT)
Thanks to Ryan, bypassing the whole diagram -> XPS step is great.