Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用Foxit Reader和C打印PDF文件#_C#_Printing_Process_Foxit Reader - Fatal编程技术网

C# 使用Foxit Reader和C打印PDF文件#

C# 使用Foxit Reader和C打印PDF文件#,c#,printing,process,foxit-reader,C#,Printing,Process,Foxit Reader,我的程序通过PDF阅读器Foxit阅读器在一个新的过程中以静默方式打印 有时,我的程序试图同时打印两个PDF,这会导致其中一个无法打印 这是我的密码: string filename = "file.pdf"; string fileDir1 = @"C:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe"; Process pdfProcess = new Process(); pdfProcess.StartI

我的程序通过PDF阅读器
Foxit阅读器在一个新的过程中以静默方式打印

有时,我的程序试图同时打印两个PDF,这会导致其中一个无法打印

这是我的密码:

string filename = "file.pdf";

string fileDir1 = @"C:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe";

Process pdfProcess = new Process();
pdfProcess.StartInfo.FileName = fileDir1;
pdfProcess.StartInfo.Arguments = string.Format(@"/t {0} {1}", filename ,"pos-80");
pdfProcess.StartInfo.CreateNoWindow = true;
pdfProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(fileDir1);
pdfProcess.Start();

if (!pdfProcess.WaitForExit(2500))
{
    pdfProcess.Kill();

}

请帮助我解决此问题。

确保您已打开Foxit

using System.Diagnostics;

List<Process> Processlist = Process.GetProcesses().ToList();
运行上述代码时,您应该在输出窗口中看到Foxit进程的名称

或者,在foreach行上放置一个断点,并将鼠标悬停在列表上,以这种方式查看所有名称

bool IsFoxitProcessRunning = false;

foreach(Process p in Processlist)
{
    if(p.ProcessName == "Foxit process name here") //Replace with the name of the foxit process
    {
        IsFoxitProcessRunning  = true;

    }

}
现在,只有在尚未运行的情况下才启动新的Foxit进程

if(!IsFoxitProcessRunning)
{
    //insert code to run next foxit process here.

}
注:

  • 您可能需要实现一个队列来跟踪等待运行的PDF

  • 如果Foxit等待运行超过5或10分钟,您可能还希望提醒IT支持人员

  • 您可以选择将
    Processlist
    设置为类属性,并通过调用
    Processlist=Process.getprocesss().ToList(),使用
    计时器定期刷新Processlist
    在勾号事件上。在PDF等待打印时,每30秒左右一次


确保您打开了Foxit

using System.Diagnostics;

List<Process> Processlist = Process.GetProcesses().ToList();
运行上述代码时,您应该在输出窗口中看到Foxit进程的名称

或者,在foreach行上放置一个断点,并将鼠标悬停在列表上,以这种方式查看所有名称

bool IsFoxitProcessRunning = false;

foreach(Process p in Processlist)
{
    if(p.ProcessName == "Foxit process name here") //Replace with the name of the foxit process
    {
        IsFoxitProcessRunning  = true;

    }

}
现在,只有在尚未运行的情况下才启动新的Foxit进程

if(!IsFoxitProcessRunning)
{
    //insert code to run next foxit process here.

}
注:

  • 您可能需要实现一个队列来跟踪等待运行的PDF

  • 如果Foxit等待运行超过5或10分钟,您可能还希望提醒IT支持人员

  • 您可以选择将
    Processlist
    设置为类属性,并通过调用
    Processlist=Process.getprocesss().ToList(),使用
    计时器定期刷新Processlist
    在勾号事件上。在PDF等待打印时,每30秒左右一次


我不是Foxit软件的专家,但从表面上看,Foxit似乎存在多任务问题。为了解决这个问题,我会尝试编写一个队列系统来监控Foxit进程,并且只在没有其他Foxit进程运行的情况下启动一个新的队列系统。非常感谢您的回答是的,您是正确的,出现这个问题是因为多任务,但我不知道如何解决它。当foxit reader打印文件时,有时显示错误,进程无法访问文件“带路径的文件”,因为它正被另一进程使用。我不是foxit软件的专家,但表面上看来foxit存在多任务问题。为了解决这个问题,我会尝试编写一个队列系统来监控Foxit进程,并且只在没有其他Foxit进程运行的情况下启动一个新的队列系统。非常感谢您的回答是的,您是正确的,出现这个问题是因为多任务,但我不知道如何解决它。当foxit reader打印文件时,有时显示错误,进程无法访问文件“带路径的文件”,因为它正被另一进程使用。