首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Acrobat插件打印多个PDF (axAcroPDF1)

使用Acrobat插件打印多个PDF (axAcroPDF1)
EN

Stack Overflow用户
提问于 2009-08-04 06:46:43
回答 1查看 3.2K关注 0票数 0

我有一个windows应用程序,我想要在列表框中向打印机发送PDF的列表。浏览下面的代码,我可以看到*axAcroPDF1.LoadFile(s)正在加载我的应用程序中的每个文件,但Acrobat似乎只将lbPDFList列表框中的最后一项打印到打印机(例如:如果有4个PDF要打印,它总是只打印最后一个PDF)?

代码语言:javascript
复制
 int iListCounter = lbPDFList.Items.Count;
                for (int i=0; i < iListCounter; i++)
                {
                    String s = null;
                    lbPDFList.SetSelected(i,true);
                    s = lbPDFList.SelectedItem.ToString();
                    axAcroPDF1.LoadFile(s);
                    axAcroPDF1.Show();
                    axAcroPDF1.printAllFit(true);
                }

这是线程问题吗?

EN

回答 1

Stack Overflow用户

发布于 2009-08-11 06:18:56

答案很简单!忽略axAcroPDF对象,只使用windows打印函数打印(使用循环中的以下代码打印每个PDF):

代码语言:javascript
复制
 // start a new cmd process
        Process objP = new Process();
        objP.StartInfo.FileName = strFilePath;
        objP.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;         //Hide the window. 
    //!! Since the file name involves a nonexecutable file(.pdf file), including a verb to specify what action to take on the file. 
    //The action in our case is to "Print" a file in a selected printer.
    //!! Print the document in the printer selected in the PrintDialog !!//
    objP.StartInfo.Verb = "printto";
    objP.StartInfo.Arguments = "/p /h \"" + strFilePath + "\" \"" + pd.PrinterSettings.PrinterName + " \"";//pd.PrinterSettings.PrinterName;
    objP.StartInfo.CreateNoWindow = true;   //!! Don't create a Window. 
    objP.Start();                           //!! Start the process !!// 
    objP.CloseMainWindow();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1225969

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档