pregunta
pregunta

Reputation: 138

Print PDF using AcroRd32.exe and powershell not working

I am trying to print a PDF using powershell and AcroRd32.exe and now run into a problem I can't solve by myself. If I am executing the code and Acrobat Reader opens but no print job is generated. I can even see my pdf in the latest use files.

This is my code:

$file = "C:\temp\file.pdf"
$adobe = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
$driver = "HP Universal Printing PCL 6"
$port = "10.200.1.63:3910"

$printer = "\\pserver\printer07"
$arglist = "/s /t $($file) $($printer) $($driver) $($port)"
Start-Process $adobe -argumentlist $arglist -wait

I tried the following:

  1. Checking if the file I am trying to print exists and is accessible [YES]
  2. Tried to print with dialog: argument "-p $($filename) [WORKS]
  3. Checked if the printer is accessible by the computer [YES]
  4. Double checked printername, driver and port... [YES]

Even without driver and port I am not able to print a file through this code.

Does anyone have useful tips or suggestions to solve this problem?

Upvotes: 1

Views: 2322

Answers (1)

marsze
marsze

Reputation: 17074

This might be the cause of your problem or not, but there are spaces in $driver, so you definitely need to add quotes in the command line (I did it for all variables, just in case):

$arglist = "/s /t `"$file`" `"$printer`" `"$driver`" `"$port`""

Upvotes: 1

Related Questions