PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
print a pdf: close adobe after print https://forum.pdfsharp.net/viewtopic.php?f=2&t=1396 |
Page 1 of 1 |
Author: | sidney [ Fri Oct 29, 2010 8:58 am ] |
Post subject: | print a pdf: close adobe after print |
hi guys i'm a new pdfsharp user ![]() i've got a question for you.i'm developing a little library that launch a print with two parameters: a pdf file path and a printer name. after the print, adobe reader doesn't close itself and i have to close it manually.how could i solve this problem? here is my simple library Code: public class Printer { public void PrintPDF(string strPdfPath, string strPrinterName, string strAdobePath) { PdfFilePrinter.AdobeReaderPath = @strAdobePath; PdfFilePrinter printer = new PdfFilePrinter(@strPdfPath, strPrinterName); try { printer.Print(); } catch (Exception ex) { } } } i've noticed that in the pdfsharp library, before process launch, the directive is to "wait" forever, so it doesn't close automatically.how could i do? from pdfsharp library... Code: try
{ //DoSomeVeryDirtyHacksToMakeItWork(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = PdfFilePrinter.adobeReaderPath; string args = String.Format("/t \"{0}\" \"{1}\"", this.pdfFileName, this.printerName); Debug.WriteLine(args); startInfo.Arguments = args; startInfo.CreateNoWindow = true; startInfo.ErrorDialog = false; startInfo.UseShellExecute = false; if (this.workingDirectory != null && this.workingDirectory.Length != 0) startInfo.WorkingDirectory = this.workingDirectory; Process process = Process.Start(startInfo); if (!process.WaitForExit(milliseconds)) //this line tell that the program have to wiat forever until manual adobe close { // Kill Adobe Reader/Acrobat process.Kill(); } } |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |