Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2314

IE / Print as PDF

$
0
0

Hallo allseits,ich versuche gerade (vergeblich), eine best. Seite automatisiert als PDF auszudrucken. Dazu habe ich PDF24 installiert (ermöglicht das Ausdrucken als PDF), und folgendes CodeSchnippsel geschrieben:

$ie = new-object -com "InternetExplorer.Application"
$ie.Navigate("https://doku.seu.sozvers.at/confluence_secure/display/DWHPC/SVMM+TelKoProtokoll")
while ( $ie.busy ) { Start-Sleep -second 5 }
$ie.visible = $true
$ie.ExecWB(6,2)
Start-Sleep -second 5
while ( $ie.busy ) { Start-Sleep -second 5 }
$ie.quit()

Mein Problem: Das funktioniert nur bei manchen Seiten. Teste ich obiges beispielsweise mit der URL "www.heise.de", klappt alles völlig problemlos - Der Code ist also anscheinend korrekt.

Bei der URL die ich brauche klappt's allerdings nicht, da bekomme ich folgende Fehlermeldung:

PS > C:\TestScripts\Convert_Html2Pdf.ps1

Es wurde versucht, ein Drop-Ziel zu widerrufen, das nicht registriert wurde. (Ausnahme von HRESULT: 0x80040100 (DRAGDROP_E_NOTREGISTERED))
In C:\Users\31300035\PowerShell\TestScripts\Convert_Html2Pdf.ps1:5 Zeichen:1
+ $ie.ExecWB(6,2)+ ~~~~~~~~~~~~~~~+ CategoryInfo          : OperationStopped: (:) [], COMException+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
Der RPC-Server ist nicht verfügbar. (Ausnahme von HRESULT: 0x800706BA)
In C:\Users\31300035\PowerShell\TestScripts\Convert_Html2Pdf.ps1:8 Zeichen:1
+ $ie.quit()+ ~~~~~~~~~~+ CategoryInfo          : OperationStopped: (:) [], COMException+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

Any hints?

LG., Michael

PS: Den "ExecWB"-Aufruf hab ich mir von hier abgeschaut:

https://stackoverflow.com/questions/58167457/how-to-use-execwb-command-for-printing-pages-as-pdf


Viewing all articles
Browse latest Browse all 2314


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>