Printing an image from file on a network

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hutt
    New Member
    • Jan 2008
    • 5

    Printing an image from file on a network

    Hi,

    asp.net (vb).
    I have developed a site in test on my PC which runs a process and outputs a jpeg image to a folder in C:\inetpub\wwwr oot\images, and I can print it from a button on my page using vb with document.print( ).
    However, when I move the site to our server the print no longer works. I understand this is because the image is now on the server along with the vb code.
    So my question is how can a client on a network get the image file from the server and print it with the simple click of a button on the web page? I have tried looking into Javascript to do this, but all I can find are examples that print the current page, not an image file from a server.
    Thank you.
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    This is probably easier than you think. Use an IP or domain to access page and print image (IIS). On a large network you will have a server that hosts your (intranet) application. HTH.

    Comment

    • Hutt
      New Member
      • Jan 2008
      • 5

      #3
      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 DocumentPrintPa ge(ByVal sender As Object, ByVal e As System.Drawing. Printing.PrintP ageEventArgs)
      Dim theCompleteImag e As New Drawing.Bitmap( "C:\Inetpub\www root\Prints\" + _imgStr + ".jpg")
      Try
      'Actual image is larger, this will fit to print page A4P
      e.Graphics.Draw Image(theComple teImage, 0, 0, 740, 1110)
      Finally
      theCompleteImag e.Dispose()
      End Try
      End Sub

      Public Sub PrintMethod(ByV al strInput As String)
      _imgStr = strInput 'the image name
      Dim document As New Drawing.Printin g.PrintDocument ()
      AddHandler document.PrintP age, AddressOf DocumentPrintPa ge
      document.Print( )
      End Sub
      Last edited by Hutt; Feb 18 '08, 02:00 PM. Reason: Add code

      Comment

      • kenobewan
        Recognized Expert Specialist
        • Dec 2006
        • 4871

        #4
        Hint - IP or domain replaces your local drive. HTH.

        Comment

        • Hutt
          New Member
          • Jan 2008
          • 5

          #5
          Originally posted by kenobewan
          Hint - IP or domain replaces your local drive. HTH.
          Hi,
          If I change the line to:
          Dim theCompleteImag e As New Drawing.Bitmap( "http://localhost/Prints/" + _imgStr + ".jpg")
          and run the app it highlights this line of code, with a message 'URI formats are not supported'. What am I missing?
          Thanks.

          Comment

          • kenobewan
            Recognized Expert Specialist
            • Dec 2006
            • 4871

            #6
            Must admit that was a surprize, apparently you use Server.MapPath( ).

            Comment

            • DISIRON
              New Member
              • Feb 2008
              • 1

              #7
              I've got the same problem. This link will help you:

              Good luck!

              Comment

              Working...