 
            | PDF Xpress for .NET - User Guide > How To > Load PDF from Memory | 
PDF Xpress™ supports opening a PDF document from memory.
To load an existing PDF file in memory:
|  | PDF Xpress can load any well-formed PDF up to PDF version 1.7. | 
| C# Example | 
                        Copy Code
                     | 
|---|---|
| 
            // This code demonstrates loading a PDF document from memory
            PdfXpress pdfx = null;
            Document document = null;
            OpenOptions oo = null;
            IntPtr globalHandle = IntPtr.Zero;
            try
            {
                pdfx = new PdfXpress();
                pdfx.Initialize(null, null);
                oo = new OpenOptions();
                byte[] buffer;
               
                using (FileStream fs = new FileStream("C:\\test.pdf", FileMode.Open))
                {
                    buffer = new byte[fs.Length];
                    fs.Read(buffer, 0, (int)fs.Length);
                    globalHandle = Marshal.AllocHGlobal((int)fs.Length);
                }
                Marshal.Copy(buffer, 0, globalHandle, buffer.Length);
                document = new Document(pdfx, oo, globalHandle);
            }
            catch (System.Exception)
            {
            }
            finally
            {
                Marshal.FreeHGlobal(globalHandle);
                if (null != document)
                {
                    document.Dispose();
                }
                if (null != pdfx)
                {
                    pdfx.Dispose();
                }
            }
 | |