Output from wshShell.Run() in PHP (RESOLVED)

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
Aybabtu
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Sep 27, 2018 4:39 am

Thu Sep 27, 2018 4:51 am

Good Morning,

I am trying to combine PDF files using pdftk using PHP and COM objects. I am looking to get an output of what the wshShell.Run() command is generating since it is not creating the output file. Here is a snippet of my code where I need to get the output.

Code: Select all

  $command = "\"C:/Program Files (x86)/PDFtk Server/bin/pdftk.exe\" ".$pdfMerge."cat output F:/Websites/SOMEPATHWITHNOSPACES/Reprint/out.pdf";

  $WshShell = new COM("WScript.Shell");
  $WshShell->Run($command);
I have run an echo on $command and put the exact value returned into the server command prompt and it does work.

Aybabtu.
Last edited by Aybabtu on Thu Sep 27, 2018 7:28 am, edited 1 time in total.

Aybabtu
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Sep 27, 2018 4:39 am

Thu Sep 27, 2018 7:27 am

Got it working using the following code

Code: Select all

  $command = "cmd /C \"C:/Program Files (x86)/PDFtk Server/bin/pdftk.exe\" ".$pdfMerge."cat output F:/Websites/SOMEPATHWITHNOSPACES/Reprint/out.pdf 2>&1";
  system($command);

Post Reply