3

I am currently using the below code for printing a pdf using Foxit Reader software. Now my problem is I want to print multiple copies of a file. Could anyone let me know how to specify the number of copies while printing a pdf in the below code.

[Edit] I dont want to use a loop to print multiple copies of pdf. I want to specify it only as a command line argument.

Any help much appreciated :)

Process process = new System.Diagnostics.Process();
process.EnableRaisingEvents = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.FileName = foxitReaderInstalledPath;
string arguments = String.Format(@"-t ""{0}"" ""{1}""", this.Path, printerName);
process.StartInfo.Arguments = arguments;
process.Start();
process.WaitForExit();
Bhaskar
  • 1,680
  • 7
  • 26
  • 40

2 Answers2

5

According to the Foxit manual there is no option to do what you want except with a loop (which you don't want to use).

Either you use some PDF library for .NET -there are plenty free and commercial ones out there (see for example .NET library to print PDF files )- or you use for example Acrobat reader for printing (IIRC it has a commandline switch to achieve what you want)...

Community
  • 1
  • 1
Yahia
  • 69,653
  • 9
  • 115
  • 144
3

Just put that in a loop. You can always manipulate the termination of the process later. It'd be nice to put it in the Arguments, but I don't think FoxIt supports it that I know of.

int numberOfCopies = 2;
Process process = new System.Diagnostics.Process();

for (int i = 1; i <= numberOfCopies; i++)
    {
            process.EnableRaisingEvents = false;
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.FileName = foxitReaderInstalledPath;
            string arguments = String.Format(@"-t ""{0}"" ""{1}""", this.Path, printerName);
            process.StartInfo.Arguments = arguments;
            process.Start();
    }
apollosoftware.org
  • 12,161
  • 4
  • 48
  • 69
  • No, I dont want run in a loop. As this will create multiple spools. This will be an issue if multiple users are printing. I want to specify it in the command line argument. – Bhaskar Sep 12 '11 at 04:43
  • I'm not sure if it supports it. FoxIt's parameters aren't too extensive. Now Adobe Reader, you may be able to do something with it. You can use the embedded PDF view into your C# application, and manipulate it that way. Printing if it's not external to your application will make it easier. – apollosoftware.org Sep 12 '11 at 04:45
  • There's also a good framework called PDFSharp. The link is http://www.pdfsharp.com/PDFsharp/ – apollosoftware.org Sep 12 '11 at 04:47
  • Foxit Reader doesn't suuport it seems :( sad. – Bhaskar Sep 12 '11 at 05:02
  • Sorry bro! Take a look into PDFsharp if you're feeling adventurous – apollosoftware.org Sep 12 '11 at 05:06