1

Here is my issue: on my webpage I'm displaying an image that been taken from a given URL (the image been display in a div).On the backhand I'm setting up the URL with all the information. Beside the fact that I'm showing the picture I want to print the page - means print the div with all the content...Now when I'm trying to print Because of the image that been take from the given URL I'm getting empty place where the image should be.

In order to solve it I figure it out that I need to do something in the background to save the image from the given URL so I have this code below.... How can I send what I'm getting from function to JS Code in order to combined the missing part when I print????

If someone have other solution please help me....

The URL of the Image : https://freemobilewallpaper.files.wordpress.com/2009/10/kuala3.jpg

JS Function:

//============================== //
      // Print Map//
      // ============================== //
      function printDiv() {

          How Can I print what been set in the code behind?????@#!@
          var test = document.getElementById("<%= divRightWrapper.ClientID %>");
          document.body.innerHTML = test;
          var newWin = window.open();
          newWin.document.write(test.innerHTML);
          newWin.print();
      }

Back Code:

Dim img As Image = GetPicture(urll)
 How to send it to JS?????!@#$!


Private Function GetPicture(ByVal url As String) As Image
        Try
            url = Trim(url)
            If Not url.ToLower().StartsWith("http://") Then url _
                = "http://" & url
            Dim web_client As New WebClient()
            Dim image_stream As New  _
                MemoryStream(web_client.DownloadData(url))
            Return Image.FromStream(image_stream)
        Catch ex As Exception

        End Try
        Return Nothing
    End Function
Huy Zukerman
  • 215
  • 1
  • 3
  • 11
  • tags already expect a URL; why do you need a server to show the image? – dandavis Jan 14 '15 at 18:38
  • I made some progress and I changed the code little bit: '# Saving the image from remote URL Dim CGURL As String = "https://freemobilewallpaper.files.wordpress.com/2009/10/kuala3.jpg" Dim req As WebRequest = WebRequest.Create(CGURL) Dim response As WebResponse = req.GetResponse() Dim stream As Stream = response.GetResponseStream() Dim img As Image = Image.FromStream(stream) stream.Close() Now How Can I send the image to JS?!?!??! – Huy Zukerman Jan 14 '15 at 18:40
  • what's wrong with the dataURL-based img src linked on the answer? – dandavis Jan 14 '15 at 18:42
  • image tag getting a url but the url been changed all the time with diff data. – Huy Zukerman Jan 14 '15 at 18:48

2 Answers2

0

Basic solution:

Use a printable version page and then popup a window with that page.

Tanmay Majumder
  • 392
  • 1
  • 4
  • 17
0

I think you can pass 64base encoded version of image.

Check this: Is it possible to put binary image data into html markup and then get the image displayed as usual in any browser?

Community
  • 1
  • 1
user1924375
  • 10,581
  • 6
  • 20
  • 27