Click here to Skip to main content
15,936,409 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys, then I explain what I have to do: within the Immagine variable there is a pdf, I should convert it into a memory steam and view it through the application default from the operating system to open the pdf, do you have any advice on how to do?

What I have tried:

using System;
using System.Drawing;
using System.IO;

namespace App.View
    public partial class VisualizzazioneDocumenti : MaterialSkin.Controls.MaterialForm
        public byte[] Immagine;

        public VisualizzazioneDocumenti()

        private static Bitmap ByteToImage(byte[] blob)
            MemoryStream mStream = new MemoryStream();
            byte[] pData = blob;
            mStream.Write(pData, 0, Convert.ToInt32(pData.Length));
            Bitmap bm = new Bitmap(mStream, false);
            return bm;

        private void VisualizzazioneDocumenti_Load(object sender, EventArgs e)
            this.pictureBoxImmagine.Image = ByteToImage(Immagine);
Updated 8-Apr-18 19:11pm

As far as I know there is no way to hand a memory stream to any existing PDF viewer app, so you would have to use a PDF viewer component within your application. And I wouldn;t expect such to exist, given that a stream is part of the memory allocated to your app, and that isn't normally available to external applications.

There are some available which will do it: Free PDF Viewer Component - Read/View/Print PDF in C#,VB.NET | Spire.PDFViewer[^] provides a "community edition" which is limited to 10 pages but which can work directly from a stream. There may be others, but you'll have to work with Google to find out.
Share this answer
rikidev 6-Apr-18 5:39am    
OriginalGriff 6-Apr-18 5:44am    
You're welcome!
Better open the pdf with default application.




Try to add COM components of Adobe Reader or other Pdf Viewer.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900