Reputation: 5
Im trying to save a pdf file as a new pdf but printting it (required), Im using Adobe Acrobat to do that cause it brings me the option to introduce parameters. The thing is : I need to do it silently (Not a single Window can been saw). So I need to set a printer, a path to my file and an output destination. As I said I need to "print it" as a new pdf so I'm using Microsoft Print to PDF to do that (I don't know if it is the better option).
Thank you so much!
string file = name;
string pathFile = "C:\\DfPrinter\\" + name;
ProcessStartInfo infoPrintPdf = new ProcessStartInfo();
string printerName = "Microsoft Print to PDF";
infoPrintPdf.FileName = "C:\\Program Files (x86)\\Adobe\\Acrobat Reader DC\\Reader\\AcroRd32.exe";
infoPrintPdf.Arguments = string.Format("/t" + " '" + pathFile + "'" +"' " +"'"+printerName+"'");
infoPrintPdf.CreateNoWindow = true;
infoPrintPdf.UseShellExecute = false;
infoPrintPdf.WindowStyle = ProcessWindowStyle.Hidden;
Process printPdf = new Process();
printPdf.StartInfo = infoPrintPdf;
printPdf.Start();
System.Threading.Thread.Sleep(10000);
if (!printPdf.CloseMainWindow())
printPdf.Kill(); printPdf.WaitForExit();
Upvotes: 0
Views: 561
Reputation: 1943
I don't think Acrobat Reader can print silently, but you could consider using the Win2PDF "printpdf" command line:
win2pdfd.exe printpdf "filename.pdf" Win2PDF "newfilename.pdf"
This prints the PDF silently to a new PDF specified by "newfilename" by using the Win2PDF printer.
Upvotes: 1