Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Byte[] of PDF into image

Byte[] of PDF into image

Scheduled Pinned Locked Moved WPF
graphicsdesigndata-structurestoolsperformance
5 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GomathiR
    wrote on last edited by
    #1

    Hi, I need to convert a byte[] array generated from PDF into image and show it in the UI. I dnt want to store the image file anywhere in the disk.Conversion should be using in-built memory. I tried to convert byte into bitmap image using the following code. But image is not rendered in the UI. using (MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length)) { BitmapImage im = new BitmapImage(); im.SetSource(ms); this.pdfImage.Source = im; } Is there anyother way to do this? Tools are also acceptable.

    Gomathi R

    P 1 Reply Last reply
    0
    • G GomathiR

      Hi, I need to convert a byte[] array generated from PDF into image and show it in the UI. I dnt want to store the image file anywhere in the disk.Conversion should be using in-built memory. I tried to convert byte into bitmap image using the following code. But image is not rendered in the UI. using (MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length)) { BitmapImage im = new BitmapImage(); im.SetSource(ms); this.pdfImage.Source = im; } Is there anyother way to do this? Tools are also acceptable.

      Gomathi R

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      You can't convert a PDF into an image simply by converting it into a byte array. Without the conversion to an image, the BitmapImage identifies that it cannot display the byte array, so it doesn't attempt to display it. You might want to try this[^] library for the actual conversion (there's even a small sample on saving a PDF to a png file).

      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

      G 1 Reply Last reply
      0
      • P Pete OHanlon

        You can't convert a PDF into an image simply by converting it into a byte array. Without the conversion to an image, the BitmapImage identifies that it cannot display the byte array, so it doesn't attempt to display it. You might want to try this[^] library for the actual conversion (there's even a small sample on saving a PDF to a png file).

        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

        CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

        G Offline
        G Offline
        GomathiR
        wrote on last edited by
        #3

        Hi Pete, I have tried this. But i am unable to add the dll in my Silverlight Application.

        Gomathi R

        P 1 Reply Last reply
        0
        • G GomathiR

          Hi Pete, I have tried this. But i am unable to add the dll in my Silverlight Application.

          Gomathi R

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          You don't add it to the Silverlight side - you add it to the ASP.NET side, and send the byte array to the Silverlight app. That is, after all, where you are getting the PDF from isn't it?

          *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

          CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

          G 1 Reply Last reply
          0
          • P Pete OHanlon

            You don't add it to the Silverlight side - you add it to the ASP.NET side, and send the byte array to the Silverlight app. That is, after all, where you are getting the PDF from isn't it?

            *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

            "Mind bleach! Send me mind bleach!" - Nagy Vilmos

            CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

            G Offline
            G Offline
            GomathiR
            wrote on last edited by
            #5

            Even in asp .net i am unable to add the dlls. I have added libpdf dll and tried to run the code. I got the following error. Could not load file or assembly 'libpdf.DLL' or one of its dependencies. The specified module could not be found.

            Gomathi R

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups