views:

12

answers:

1

I have an ActiveX control which has a function for opening a document directly from memory. The function has the following signature:

Public Overridable Function OpenPDFFromMem(ByVal lpPDFData As Integer, ByVal nPDFDataLen As Integer, ByVal lpszUserPwd As String, ByVal lpszOwnerPwd As String) As Boolean

How do I load the document in memory and pass correct parameters to this function?

Thanks.

A: 

I figured it out myself, works seamlessly.

Dim filePath As String = "c:\TEST.pdf"
Dim buff() = File.ReadAllBytes(filePath)

Dim mem As IntPtr = Marshal.AllocCoTaskMem(buff.Length)

Marshal.Copy(buff, 0, mem, buff.Length)

viewer.OpenPDFFromMem(mem, buff.Length, Nothing, Nothing)
Sphynx