Spool problems when printing pdf with dcom office interop

Hi there,

having problems getting my code to work. Could need some advice :slight_smile:

I installed pdfcreator as local printer. Using powershell code to create an dcom instance for the queue access.

$PDFCreator = New-Object -ComObject PDFCreator.JobQueue
$PDFCreator.Initialize()

Now when i open microsoft word in the GUI, and issue a print order to my default printer the document is spooled to pdfcreator
Pdfcreator log is populated.
“$PDFCreator.counts” returns 1 and the files are located in “C:\users%username%\AppData\Local\Temp\2\PDFCreator\Spool*” great.
Furhter processing with “$job = $PDFCreator.NextJob” works fine.

But my actual idea is to print in a headless session using dcom word automation.
Invoking basically the following:

$wordApp = New-Object -ComObject Word.Application
$wordapp.ActivePrinter # -> displays the default printer, looks good so far
$wordDocument = $wordApp.Documents.Open(“C:\path\file.doc”,$false,$true)
$wordDocument.PrintOut($false)
Pdfcreator log does NOT show ANY log activity(!)
“$PDFCreator.counts” returns 0 and the files are now located in “C:\users%username%\AppData\Local\Temp\PDFCreator\Spool*”
Note the “\2” is missing in the path.

When comparing the .PS associated .inf files, I recognized a difference in some lines

.inf from “C:\users%username%\AppData\Local\Temp\2\PDFCreator\Spool*” -> GUI WORD created starts with:
[0]
SessionId=2
WinStation=RDP-Tcp#3

.inf from “C:\users%username%\AppData\Local\Temp\PDFCreator\Spool*” -> DCOM WORD created starts with:
[0]
SessionId=0
WinStation=Services

Modifying the file content and moving it to the “other” directory did not cause $PDFCreator instance to find the files, as i hoped.
$PDFCreator.Count still returns 0

Any idea what i could do to solve that problem?

Best Regards,
Michael

Some additional information:

Something i currently not understand (may not relate, thought i just add it for completion)
When I change to “background=true” printing with the “$worddocument.printout($true)” code.
The files get spooled to “C:\windows\system32\spool\printers” and nothing happens either.
The files are now shown in the windows PDFCreator spooler dialog, status “spooling” and nothing changes"

(…same code as above…)
PS C:\Windows\system32> (Get-Printer)[0]
Name ComputerName Type DriverName PortName Shared Publishe
d


PDFCreator Local PDFCreator pdfcmon False False

PS C:\Windows\system32> $wordapp.ActivePrinter
PDFCreator on NE00:

PS C:\Windows\system32> $wordDocument.PrintOut($true)

PS C:\Windows\system32> $PDFCreator.Count
0
PS C:\Windows\system32> Get-PrintJob (Get-Printer)[0]

Id ComputerName PrinterName DocumentName SubmittedTime JobStatus


9 PDFCreator Microsoft Word - … 11.10.2016 13:19:50 Spooling
20 PDFCreator Microsoft Word - … 11.10.2016 15:42:25 Spooling
23 PDFCreator Microsoft Word - … 11.10.2016 18:52:13 Spooling

Wondering why the port shows “NE00:” in dcom and the printer is bound to “pdfcmon”, not too deep in that printing topics… (yet…) >_<

Hi,

the original problem here is the headless session; PDFCreator always needs a user logged on, it can’t run in session 0.

Best regards,

Robin

Thanks for the wrap-up. Already gave up on that :slight_smile: