Two Pilots™    Home  |  Navigation  |  Site Map  |  Products  |  Download  |  Prices  |  For Partners  |  Support

All forums · Statistics · Search ·

Two Pilots forum / For software developers / How to use IPDFDocument4.OpenFromBLOB()
Author Message
# Posted: 16 Mar 2010 05:04


HRESULT OpenFromBLOB (VARIANT* document,BSTR password)

Overall I have no idea how to pass my memory buffer as VARIANT*, there is no example in the help. Please suggest how to use it.

# Posted: 16 Mar 2010 13:56


Let's pretend we have an array of bytes that represenst the PDF document
(we might have read it from the file or from the database or elsewhere).

Here is a sample code, how to create VARIANT from your array (C++ code):

BYTE* p_arraySource; // our array
size_t size; // size of the array

// we suppose you have read the PDF file data into this array
p_arraySource = ...
size = ...

// create VARIANT object
VARIANT* p_variant = new VARIANT();

// our VARIANT will be the array (SAFEARRAY)
SAFEARRAY* pSafeArray;
aDim[0].lLbound = 0;
aDim[0].cElements = (ULONG)size;
p_variant->vt = VT_ARRAY | VT_UI1;

// create and fill SAFEARRAY
pSafeArray = SafeArrayCreate(VT_UI1, 1, aDim);
BYTE* dwArray = 0;
SafeArrayAccessData(pSafeArray, (void**)&dwArray);
memcpy(dwArray, p_arraySource, size);
p_variant->parray = pSafeArray;

// now we're ready to pass the VARIANT to the PDF Creator Pilot
CComBSTR passwd = "password";
p_PDF->OpenFromBLOB(p_variant, (BSTR)passwd);

// now the document is opened

// clear resources
delete p_variant;

Max Filimonov,

# Posted: 17 Mar 2010 02:07

Thank you Max.



Powered by miniBB 2.0 RC7 © 2001-2004 Page creation time (sec.): 0.015


Page top