Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 430765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:54:28+00:00 2026-05-12T19:54:28+00:00

This is most likely not an easy one but here is the situation: I

  • 0

This is most likely not an easy one but here is the situation:

I have written a C# command line application which:

  • creates a PDF using ITextSharp
  • writes it to disk
  • uses Acrord32.exe (this is Acrobat Reader) via System.Diagnostics.Process in order to silently print the generated PDF

If I build my solution and double click the pdfGen.exe, it works as expected. The PDF is created and printed.

Now, my app has to be deployed on a internal server with Windows Vista running IIS 7. This server has some PHP webapp running. And it will be called via PHP using shell_exec() so that the resulting PDF will be printed on the printer attached to the server.

So my PHP page looks basically like this:

shell_exec('/path/to/pdfGen.exe');

But here things go wrong. What happens is according to task manager etc.:

  • pdfGen.exe starts
  • the PDF is created
  • Acrord32.exe starts
  • pdfGen.exe hangs forever (and so does the PHP script) and nothing is printed

I am pretty sure it is some permission related problem. I already gave IIS_IUSRS access to the default printer, and to the directory where Acrord32.exe is located. But still, no printing. However, if I start my pdfGen.exe manually it works.

Any idea what I am missing?

EDIT:

I am not bound to use Acrobat Reader in order to print the PDF. If there is another way in order to silently print the created PDF serverside, I would not mind at all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T19:54:28+00:00Added an answer on May 12, 2026 at 7:54 pm

    Thanks all for your comments. Unfortunately this “php start printjob” thing was part of a larger project that was cancelled today because of, well… I dont know… political reasons. Guess the project is pretty much dead.

    Anyway, I tried myself a few more times in the last days and could not get it to work with IIS. My solution that I implemented and tested already: remove IIS, install a XAMPP or WAMPP package with a local apache and PHP that runs with admin access rights.

    This did the trick. I used pclose(popen('...command...', 'r')); in PHP in order to start the .exe and so that PHP does not wait until the PDF is finished. It all worked great.

    Here is my C# code which starts the print job using Acrobat Reader

    public void Print(string pathname, string acrobatDirectory)
    {
        var proc = new Process
        {
            StartInfo =
            {
                Arguments               = String.Format("/t \"{0}\"", pathname),
                FileName                = acrobatDirectory,
                UseShellExecute         = false,
                CreateNoWindow          = true,
                RedirectStandardOutput  = false,
                RedirectStandardError   = false,
            }
        };
    
        proc.Start();  
    }  
    

    The first argument is the path to the PDF that should be printed, the second parameter is the absolute path to the AcroRd32.exe.

    The only problem left was that AcroRd32.exe was started, printed and never got closed again. So every printjob started a new instance of AcroRd32.exe (I am using Acrobat Reader 9.0). So if you printed 10 times, 10 acrobat reader instances were created.

    What I did was starting the print job, then waiting X seconds, hoping that the printer was finished and then killing all AcroRd32.exe instances:

    public void Print(string pathname, string acrobatDirectory)
    {
        Debug.WriteLine("Printing...");
    
        Printer.Print(pathname, acrobatDirectory);
    
        Thread.Sleep(30000);
    
        try
        {
            Debug.WriteLine("Trying to kill runnung AcroRd32.exe's ");
    
            FindAndKillProcess("AcroRd32");
        }
        catch (Exception)
        {
            Debug.WriteLine("AcroRd32.exe could not be killed...");
        }
    }
    
    private bool FindAndKillProcess(string name)
    {
        foreach (Process clsProcess in Process.GetProcesses())
        {
            if (clsProcess.ProcessName.StartsWith(name))
            {
                clsProcess.Kill();
                return true;
            }
        }
    
        return false;
    }
    

    This worked out quite well.


    Note that the above (killing all AcroRd32.exe and running PHP with admin privilegs) was only doable because: The whole thing is only used by one user at a time and has a very limited area of use.

    It should be used on a touchscreen application deployed at the clients POS. A salesman would use the PHP app in order to configure a product, and then PHP would call my .exe which would create and print a PDF in the background. The printed document is then handed to the client. So security etc. was not really a concern in this case.


    If anyone has a solution in order to use it with IIS, I am still willing to accept it as an answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize this is likely to be an easy one, but my SQL is
I have this ajax call, which works for the most part, but it does
This is not as simple as it seems. Most of you are likely thinking
I know this is most-likely a simple question but when you restore a database
I couldn't find this anywhere on the web so I'm most likely is not
I'm pulling in xml using the cocoa NSXmlParser. Since this process most likely won't
This is actually a non-critical question, but I get this warning most of the
I know this is probably rather trivial but I have had a look at
We have a system which is composed of few applications. Each application at certain
Encoding issues are among the one topic that have bitten me most often during

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.