Click here to Skip to main content
14,451,428 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi
I have some existing code in C# which sends PDF files to a printer, and it works fine. However I now need to send a PDF as double-sided, and choose an output tray, but I can't find out if this can be done from AcroRD32.EXE, and if so, how. My existing code automatically detects a new document and prints it as follows:
Process proc = new Process();
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.Verb = "print";

//Define location of adobe reader/command line
//switches to launch adobe in "print" mode
proc.StartInfo.FileName = System.Configuration.ConfigurationManager.AppSettings["AdobeReaderFilePath"].ToString();
proc.StartInfo.Arguments = String.Format(@"/p /h {0}", pdfFileName);
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

proc.Start();
if (proc.HasExited == false)
{
    proc.WaitForExit(10000);
}

proc.EnableRaisingEvents = true;

proc.Close();
KillAdobe("AcroRd32");

I can't do it using defaults on the printer itself, so am hoping for some parameter which allows control of the print options. Is this possible?

Thanks in advance.

What I have tried:

A long search has failed to find any comprehensive list of parameters for AcroRD32, nor any decent documentation for it.
Posted
Updated 18-Jun-19 21:33pm
Comments
Richard MacCutchan 17-Jun-19 9:24am
   
Try typing acrord32 /h or /? at a command prompt; it may list the options.
Member 13166671 17-Jun-19 9:34am
   
Hi Richard. Good thought, but neither of these work. Using /h is ignored, and /? just opens the interface. Thanks though.
Rate this:
Please Sign up or sign in to vote.

Solution 1

You need a printer that can handle "duplex"; commonly referred to as "2 sided" or "double sided" printing.

It's the "printer (dialog) settings" you're interested in; nothing to do with "Adobe".
   
Comments
Maciej Los 19-Jun-19 2:19am
   
Short And To The Point!
Member 13166671 19-Jun-19 6:34am
   
Hi Gerry. The printer does handle Duplex, and an old program that prints using MS Access prints duplex quite happily on it. I needed to know how to make this happen when I automatically print a PDF. From the looks of it, it can't be done with AcroRD32, so will have to look further afield. Cheers
Maciej Los 19-Jun-19 6:41am
   
Seems, you didn't understand Gery's words... Please, read them again.
Member 13166671 19-Jun-19 6:44am
   
Well the crux of the point is I need to change the printer settings, and it seems I cannot do that through AcroRD32. That was what I was trying to do, but looks like it cannot be done, so will try other tools as suggested below.
Rate this:
Please Sign up or sign in to vote.

Solution 2

There's a NuGet packet: Spire.PDF 5.6.2[^], which enables printing pdf files with several options of printing.

See:
PdfDocument pdfdocument = new PdfDocument();
pdfdocument.LoadFromFile(pdfPathAndFileName);
pdfdocument.PrinterName = "SomePrinter";
pdfdocument.PrintDocument.PrinterSettings.Copies = 2;
pdfdocument.PrintDocument.Print();
pdfdocument.Dispose();


How to check if printer enables duplex printing?
//Indicate whether the printer supports duplex
bool isDuplex = pdf.PrintDocument.PrinterSettings.CanDuplex;
//Set the printer's duplex setting: Default, Simplex, Horizontal, Vertical
if(isDuplex)
{
    pdf.PrintDocument.PrinterSettings.Duplex = Duplex.[Default];
    //print
    pdf.PrintDocument.Print();
}
   
v2
Comments
Member 13166671 19-Jun-19 8:41am
   
Hi Maciej. Thanks for this. I will check out Spire.PDF and see if it meets my needs. .Net shows CanDuplex = false, but it can (and has done for several years), but I understand this is because the printer is on the network, which can hide some characteristics. Whether that too might be a problem for me I don't know. Cheers.
Maciej Los 19-Jun-19 8:42am
   
You're very welcome.
Good luck!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100