自动将InfoPath表单转换为PDF [英] Automated conversion of InfoPath forms to PDF

查看:169
本文介绍了自动将InfoPath表单转换为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是以编程方式打开与各种InfoPath模板(20)关联的一组XML文件(〜10k),然后将填充的表单另存为PDF到网络共享中.这将是一项一次性的任务.

I've been tasked with programatically opening up a set of XML files (~10k) associated with various InfoPath templates (20) and then saving the populated forms as PDF to a network share. This will be a one-time task.

我有代码循环浏览XML文件集,并在InfoPath中打开它们.但是,记录的命令行参数不足以满足我的需要(无打印/关闭参数).

I have code to cycle through the set of XML files and open them in InfoPath. However, the documented command-line parameters are not sufficient for my needs (no print / close parameters).

谁能提供有关启动参数的建议,这些建议将告诉InfoPath打开特定文件,将其打印为PDF,然后在打印时关闭?有没有其他方法可以实现这一目标?

Can anyone provide any suggestions for startup parameters that will tell InfoPath to open a specific file, print it to PDF, and close upon printing? Is there an alternative method to achieve this goal?

我们正在使用InfoPath 2007,这些文件托管在MOSS 2007中.

We're using InfoPath 2007 and the files are hosted in MOSS 2007.

推荐答案

使用InfoPath的COM互操作程序集(添加对 Microsoft.Office.Interop.InfoPath 的引用),您可以打印XML表单带有以下代码段:

Using the COM interop assembly for InfoPath (add a reference to Microsoft.Office.Interop.InfoPath) you can print an XML form with the following snippet:

using Microsoft.Office.Interop.InfoPath;

class Program
{
    static void Main(string[] args)
    {
        Application app = new Application();
        XDocument xdoc = app.XDocuments.Open(@"C:\tmp\Form1.xml", 1);
        xdoc.PrintOut();
        app.Quit(false);
    }
}

使用默认打印机设置进行打印,但我还没有找到一种方法来更改它.但是,由于这对您来说是一项一次性的任务,因此我认为这应该不是问题.

Printing happens using the default printer settings and I haven't found a way to change that. However, as it's a one-time task for you I assume that should not be a problem.

更多的问题可能是您无法指定PDF打印机的输出文件名.也许您可以将打印机配置为使用默认名称,然后等到文件打印完毕后再移动它,然后再打印下一个文档.

More of a problem could be that you don't have a way to specify the output file name of your PDF printer. Maybe you can configure your printer to use a default name, then wait until the file is printed, move it and then print the next document.

这篇关于自动将InfoPath表单转换为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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