Thomas Mulder
Thomas Mulder

Reputation: 779

Silent print with Foxit Reader from process opens GUI

I'm having trouble with printing a PDF through Foxit Reader.. The problem is not that it's not printing, but that the GUI is loaded when trying to do so.. I would like the printing to just happen in the background...

Everything I read so far suggests that the code below is supposed to actually print in the background, yet for every print job, the Foxit GUI pops open... The GUI also closes after printing, but I don't want it to open in the first place. I am executing the code below from a Console application that hosts a WCF service if that would be important...

        ProcessStartInfo psInfo = new ProcessStartInfo();
        psInfo.FileName = FoxitReaderLocation;
        psInfo.Arguments = String.Format("/t \"{0}\" \"{1}\"",
            fileLocation,
            printerName);
        psInfo.WindowStyle = ProcessWindowStyle.Hidden;
        psInfo.CreateNoWindow = true;
        psInfo.UseShellExecute = true;
        Process process = Process.Start(psInfo);
        process.WaitForExit(10000);
        if (!process.HasExited)
        {
            process.Kill();
            process.Dispose();
        }

Printing with /p "filelocation"also works with the default printer, but the same problem with the GUI occurs. Doing this with Adobe Reader occurs silently, but doesn't print half of my files (but then again, the command line interface of Adobe Reader is not officially supported, so please don't suggest to use Adobe Reader)

Sources:

Upvotes: 3

Views: 5826

Answers (3)

kaplievabell
kaplievabell

Reputation: 811

Encountered the same problem, but got fixed when I rearranged the arguments int he string:

startInfo.Arguments = String.Format(" \"{0}\" /t  \"{1}\"",
      reportFullPath,
      printerName);

Upvotes: 1

tan9
tan9

Reputation: 3610

I think this is by design of the the new version of Foxit Reader.

Removing the latest version downloaded from official site and install older version (6.2.3) from Old Apps. The process terminated immediately after printing.

Upvotes: 3

Cheese Lover
Cheese Lover

Reputation: 460

Try setting the WindowStyle property, most windowed applications listen to it:

psInfo.WindowStyle = ProcessWindowStyle.Hidden;

Additionally, the documentation states the CreateNoWindow is n̲o̲t̲ compatible with UseShellExecute, so you should probably turn that off:

psInfo.UseShellExecute = false; //Using ShellExecute messes stuff up

However, CreateNoWindow actually specifies whether or not to use the existing console window for console apps,[1] and can be left unspecified as it has no effect on the start of GUI apps.

Upvotes: 0

Related Questions