Forum moved here!

Home / Investigating why Sumatrapdf called from PHP does not print


Running a Windows IIS with PHP FastCGI environment I want to print a full-path pdf file on a network printer.
Running the same command as domain administrator the pdf file prints successful.

As the applicationpool runs as <machinename$> I started sumulating the process without involving the intranet website at all.

I have psexec on my d:\tools directory.
Also sumatrapdf within d:\tools\SumatraPDF.

I start on the Intranetserver from a command box like:

  • “D:\Tools>psexec -s cmd”
    The “whoami” command shows:
  • “nt authority\system”
    With "set |findstr “USERNAME” it shows:
    ** the userdoamin and the username are the same for the SVCHOST -k iissvcs, as w3wp.exe and php-cgi.exe as the Intranet runs

In the dos-box I continue with expanding the PATH to include the SumatraPDF directory:

  • set PATH=D:\tools\Sumatrapdf;%PATH%

Before the expansion calling SumatraPDF.exe I get:

  • ‘sumatrapdf.exe’ is not recognized as an internal or external command operable program or batch file.

After the PATH adjustment I get no message but I proof it is running via the tasklist command like

  • tasklist /v | findstr “Sumatra”
    which returns
  • SumatraPDF.exe 808 Services 0 10,792 K Unknown NT AUTHORITY\SYSTEM 0:00:00 N/A

So I know it is started.
I kill via Taskkill:

  • taskkill /PID 808 /F
    Which returns:
  • SUCCESS: The process with PID 808 has been terminated.

The SumatraPDF.exe has not been coming to the Foreground at all.

Running the full command like:

  • SumatraPDF.exe -silent -exit-on-print -print-to \ -print-settings simplex,paper=A4,portrait
    it runs but does not print a file and %errorlevel% shows 1.

  • tasklist /v | findstr “Sumatra” does not return anything so SumatrPDF.exe existed as the parameters where specified like that, so expected behaviour.

Now running it with -console it shows via the tasklist /v | findstr “Sumatra” and also the sysinternals procexp program shows that SumatraPDF.exe is running with all the specified arguments.

Tasklist /M shows:
SumatraPDF.exe 3984 ntdll.dll, wow64.dll, wow64win.dll,
wow64cpu.dll, umppc12806.dll

As Sumatrapdf does not have a logging file to check I don’t know what is the reason for not printing the pdf file to the network printer and when I run the same steps from a dos-box as a domain adminstrator it does.

The above way I simulated as close as possible the PDF file printing from a PHP based intranet page which also does not print.

Any explanation/ideas?


A few items catch my eye

Running blind on a server is a constant source of queries and the developers short answer is in general terms “server printing is not an intended use for a viewing app”
The latest raised query suggested that since the c++ core is based on GDI components there can be problems when graphics are not as expected compared to when used in a viewing environment. Culprits such as windows KB fixes for 64 bit apps have been suggested but they could be graphics red herrings.
SO one unproven suggestion is to use 64bit latest daily. Another is to check for known GDI updates.

However many users seem to be able to eventually get it partially working because we then get other related downstream issues. for example unresolved dropping out in Need a -log commandline switch · Issue #1878 · sumatrapdfreader/sumatrapdf (

SumatraPDF can often be unforgiving if syntax is not correct so

SumatraPDF.exe -silent -exit-on-print -print-to \ -print-settings simplex,paper=A4,portrait

looks potentially wrong, so a good starting point should be

SumatraPDF.exe -silent -exit-on-print -print-to "print server name" -print-settings "simplex,paper=A4,portrait" "filepath\name.pdf"

P.S. also see When starting from Windows Service printing doesn’t work · Issue #301 · sumatrapdfreader/sumatrapdf ( for other suggestions

And there could even be gold in them there hills (sorry the number is high) but some say they resolved their issues one way or another
try Search results for ‘server & print’ - Sumatra Reader Discussion Forum (
and double check headings for wider search
Search results for ‘server’ - Sumatra Reader Discussion Forum (


For a while I could not get the program stable in usage from the command-prompt. I read a forum reply that told something about

  • some settings file created in the SumatraPDF directory
  • the -print-to argument
  • the default printer

I now tell something about

  • setting the default printer before executing the SumatraPDF executable
  • keep the arguments in a certain order

What works for me:

  • rundll32 printui.dll,PrintUIEntry /y /n “\<name of the printserver<printer name>”
  • SumatraPDF.exe -silent -exit-on-print -print-settings “simplex,paper=A4,portrait” -print-to “\<name of the printserver<printer name>”

For the PHP triggered printing I am inverstigating a PHP Library and/or the above via exec.


Thanks for the feedback, I agree

A) SumatraPDF starts by looking at the current SYSTEM default settings
So fixing the default printer to be always the same is a good move.
Beware on windows 10 the system setting ideally should NOT be to let windows manage printers, unless you are managing as here by means of printui.dll

B) Settings order can sometimes help, to ensure most consistent results, so the sequence you are using does seem to be reasonable.

Note that IF in A) the system printer defaults are always set to be “simplex,paper=A4,portrait” then they would not be needed in B), However, in a non personal environment they are likely to be fluctuating.