Try this instead. I think this works (this stupid XPS software keeps giving me a dialog...):
function Print-Bitmap
{
param (
[System.Drawing.Bitmap]$Bitmap
)
$printDocument = New-Object System.Drawing.Printing.PrintDocument
Register-ObjectEvent -InputObject $printDocument -EventName PrintPage -SourceIdentifier PrintDocument.PrintPage -Action {
param (
[System.Object]$sender,
[System.Drawing.Printing.PrintPageEventArgs]$e
)
$e.Graphics.DrawImage($Bitmap, 0, 0)
}
$printDocument.Print()
}
function Download-Image
{
param (
[String]$Url
)
$webRequest = [System.Net.WebRequest]::Create($Url)
$webResponse = $webRequest.GetResponse()
$stream = $webResponse.GetResponseStream()
return New-Object System.Drawing.Bitmap -ArgumentList $stream
}
$bitmap = Download-Image -Url "your_url_goes_here"
Print-Bitmap -Bitmap $bitmap