You must Sign In to post a response.
  • Category: .NET

    How to print the PDF file without opening the file using .net in Windows service

    How to open the PDF file through windows service without open the file or acrobat.exe in processor.

    Actually we tried the below code it was working when print through windows form with automatically file gets opened, but this is not working when printing by windows service.

    We need to do the same in windows service without opening file. please let me know if any more clarification required in this.

    public string PrintPdf(string filename)
    string FileResult = string.Empty;

    Process p = new Process();
    p.StartInfo = new ProcessStartInfo()
    CreateNoWindow = true,
    UseShellExecute = true,
    Verb = "print",
    FileName = filename,
    WindowStyle = ProcessWindowStyle.Hidden,

    if (p.HasExited == false)
    FileResult = filename;

    catch (Exception Ex)
    FileResult = string.Empty;
    return FileResult;
  • #759100
    Hello Shivasankar,

    Refer the below code :

    string pdfArguments = string.Format(" /t " + "\"" + SavePath + "\\" + _orderNumber + ".pdf\" " + "\"mySharp\"");
    //string pdfPrinterLocation = @"C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe";
    string pdfPrinterLocation = @"C:\Program Files (x86)\Foxit Software\Foxit Reader\Foxit Reader.exe";

    ProcessStartInfo newProcess = new ProcessStartInfo(pdfPrinterLocation, pdfArguments);
    newProcess.CreateNoWindow = true;
    newProcess.RedirectStandardOutput = true;
    newProcess.UseShellExecute = false;

    Process pdfProcess = new Process();
    pdfProcess.StartInfo = newProcess;
    pdfProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

    If your code is working in application than the code you have written will alsowork.

    You just have to create the console application and convert it into windows service.

    Put your function in the class and call that function in the Main().

    You are done.
    Enjoy coding.

    Hope this will help you.
    Mark the answer if it helped you.

    Nirav Lalan
    DNS Gold Member
    "If you can dream it, you can do it."

  • #759104
    we dont have foxitreader.exe. is it any way to do with Acrobatreader.exe or itextSharp?

  • #759107
    Hi Sivashankar.

    For printing pdf files with out opening the file refer below links


    DNS Member.
    "Hope for the best.. Prepare for the worst.."

    Sridhar Thota.
    Editor: DNS Forum.

  • #759668
    Hi, another option for you to print PDF with C#. You do not need to open PDF but you're able to set print dialog with code, more details -

  • #761337
    I am currently loading PDF files as images without viewing them in a service and saving them as TIFF images. I am using leadtools programming tools to support this. I think you can do the printing process in a service using their RasterImagePrinter Class as shown here:

    I hope this helps :)

  • Sign In to post your comments