如何从WinForm托管的FormControl中将InfoPath表单导出为PDF? [英] How to export an InfoPath Form as a PDF from within a WinForm hosted FormControl?

查看:108
本文介绍了如何从WinForm托管的FormControl中将InfoPath表单导出为PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#WinForm应用,该应用(除其他外)托管一个InfoPath FormControl,以允许用户填写某些表单. WinForm应用程序中提供的save方法,除了保存表单XML之外,还可以将表单导出为PDF,以便可以通过电子邮件发送PDF副本.

当我们使用InfoPath 2007时,一切运行良好.由于该公司现在正在使用Office升级所有计算机,因此从2007年到2010年,我需要更新该应用程序以与InfoPath 2010一起使用.更改所需的引用后,一切似乎都已完成.正常工作,直到保存功能尝试将表单导出为PDF为止.导出表单的代码(以前使用2007时有效)如下所示:

this.view.OutputForm.XmlForm.CurrentView.Export(pdfFile, Microsoft.Office.InfoPath.ExportFormat.Pdf);

OutputForm是一个Microsoft.Office.InfoPath.FormControl对象.调用Export方法时,将引发此异常:

InfoPath遇到错误.这 操作失败.

InfoPath无法导出表单.不 支持这样的界面

在Microsoft.Office.Interop.InfoPath.SemiTrust.View.Export(字符串bstrURL,字符串strFormat)

在Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.Export(String bstrURL,字符串bstrFormat)

Microsoft.Office.InfoPath.Internal.ViewHost.Export上的

(字符串fileLocation,ExportFormat格式) ...

我无法想象此功能刚刚从托管的InfoPath 2010 FormControl中被剥夺了吗?我真的希望事实并非如此.

这里是否有任何InfoPath向导可以指引我正确的方向(我所缺少的还是替代的解决方案)?

根据Artur Mustafin的意见,我很乐意听到有关从InfoPath表单生成PDF的替代解决方案的信息.

给遇到此问题的其他人的笔记,我发现了这个解决方案

似乎您正在使用Office加载项2007 Office扩展了对PDF 2.0文件格式的支持.

您需要(重新)安装和更新该Office 2010外接程序版本的版本. 一切都会再次无缝运行.

关于, 阿图尔·穆斯塔芬(Artur Mustafin)

遵循google.com上的白色命令行,然后跟随SaveAsPDFandXPS ...

P.S.

此外,由于COM接口,API已更改,不再支持现有方法的某些行为,引入了其他接口,因此Office 2007的外接程序将无法再用于Office 2010.请继续关注Microsoft Connect.

希望这会有所帮助.

I have a C# WinForm app that (among other things) hosts an InfoPath FormControl to allow users to fill out some forms. The save method provided in the WinForm app, in addition to saving the form XML, also exports the form as a PDF so that a PDF copy can be sent out via email.

All worked well when we were using InfoPath 2007. Since the company is now upgrading all machines with Office, from 2007 to 2010, I need to update the app to work with InfoPath 2010. After changing the required references everything seemed to be working fine, until the save function attempted to export the form to a PDF. The code to export the form, (which worked previously when using 2007), is shown below:

this.view.OutputForm.XmlForm.CurrentView.Export(pdfFile, Microsoft.Office.InfoPath.ExportFormat.Pdf);

OutputForm is a Microsoft.Office.InfoPath.FormControl object. When the Export method is called this exception is thrown:

InfoPath has encountered an error. The operation failed.

InfoPath cannot export the form. No such interface supported

at Microsoft.Office.Interop.InfoPath.SemiTrust.View.Export(String bstrURL, String strFormat)

at Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.Export(String bstrURL, String bstrFormat)

at Microsoft.Office.InfoPath.Internal.ViewHost.Export(String fileLocation, ExportFormat format) ...

I can't imagine that this functionality has just been ripped from the hosted InfoPath 2010 FormControl, has it? I really hope that is not the case.

Are there any InfoPath wizards here that can point me in the right direction, (what I'm missing or an alternate solution)?

Based on the input from Artur Mustafin I'm open to hearing about alternate solutions to generating the PDF from the InfoPath Form.

A note for anyone else coming across this I found this thread on social.msdn.microsoft.com where Bruce Song states that:

...it is a known issue from the Microsoft internal bug check system and the product group is trying to fix it.

解决方案

It seems, that you are using the Office Add-In for 2007 office which is extending support with PDF 2.0 file format.

You need to (re)install and update version of that add-in build for Office 2010. And everything will work seamlessly again.

Regards, Artur Mustafin

Follow the white command line at google.com followed by SaveAsPDFandXPS...

P.S.

Additionally, your Addins for Office 2007 will not work anymore for Office 2010 because COM interfaces, API has changed, some behavior of existing methods are not longer supported, other interfaces are introduced. Stay tuned on Microsoft Connect.

Hope it will help.

这篇关于如何从WinForm托管的FormControl中将InfoPath表单导出为PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆