PDF Xpress™ supports opening a PDF document from memory.
To load an existing PDF file in memory:
- Create a new OpenOptions object.
- Create a new Document using a byte array containing the complete PDF file.
- Create a new Document using a handle to a Global Memory buffer containing the complete PDF file.
PDF Xpress can load any well-formed PDF up to PDF version 1.7. PDF Xpress saves all documents in PDF version 1.6. |
C# Example | Copy Code |
---|---|
// This code demonstrates loading a PDF document from memory PdfXpress pdfx = null; Document document = null; OpenOptions oo= null; try { pdfx = new PdfXpress(); pdfx.Initialize(null, null); oo = new OpenOptions(); byte[] buffer; IntPtr globalHandle; 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 ex) { } finally { Marshal.FreeHGlobal(globalHandle); if ( null != document ) document.Dispose( ); if ( null != oo ) oo.Dispose( ); if ( null != pdfx ) pdfx.Dispose( ); } |