| re: Printing an image from file on a network
Hi,
Thanks for replying, but I'm relatively new to .net and need some clearer advice. Yes my application is on a network web server, and this is where the jpeg image file sits. The client could open the image in a browser to print, but that doesn't work because it only ever prints part of the image (despite changing printer settings to fit to page), and this involves another step for the user. When I host the app locally my .net code fits the image to the A4 page and prints , so I am looking for some code that will work when it is hosted on the web server and the client wants to print the image.
Below is the code that runs on my PC but not when on the server, apparently I have to use the path to the image, a URL is no good:
Sub DocumentPrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim theCompleteImage As New Drawing.Bitmap("C:\Inetpub\wwwroot\Prints\" + _imgStr + ".jpg")
Try
'Actual image is larger, this will fit to print page A4P
e.Graphics.DrawImage(theCompleteImage, 0, 0, 740, 1110)
Finally
theCompleteImage.Dispose()
End Try
End Sub
Public Sub PrintMethod(ByVal strInput As String)
_imgStr = strInput 'the image name
Dim document As New Drawing.Printing.PrintDocument()
AddHandler document.PrintPage, AddressOf DocumentPrintPage
document.Print()
End Sub
|