我有一个ActiveX控件,它具有直接从内存中打开文档的功能。该函数具有以下签名:
Public Overridable Function OpenPDFFromMem(ByVal lpPDFData As Integer,ByVal nPDFDataLen As Integer,ByVal lpszUserPwd As String,ByVal lpszOwnerPwd As String)As Boolean
如何将文档加载到内存中并将正确的参数传递给此函数?
感谢。
答案 0 :(得分:0)
我自己想出来,无缝地工作。
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)