|
PrefOutputToMemory |
Top Previous Next |
|
The PrefOutputToMemory specifies whether to create the file output in file or in memory.
Syntax
Remarks
Setting this property to True will generate the output document in memory. No file will be created. The output data can be obtained by calling the function GetMemoryBuffer. It'll return the binary data as variant.
Default Value
False
Example Code
[VC++] VARIANT varStream; void *ptr, *ptrDest; int Size; FILE *fp;
// Initialize variant. VariantInit(&varStream);
m_Engine.SetPrefOutputToMemory(true); m_Engine.SetPrefOpenAfterCreate(false); m_Engine.SetPrefShowSetupDialog(false); m_Engine.BeginDoc(); m_Engine.TextOutXY(2, 2, "Gnostice eDocEngine ActiveX"); m_Engine.EndDoc();
// Obtain the generated document stream. varStream = m_Engine.GetMemoryBuffer();
SafeArrayAccessData(varStream.parray , &ptr); Size = varStream.parray->rgsabound[0].cElements; ptrDest = new unsigned char[Size+1]; memcpy(ptrDest, ptr, Size); SafeArrayUnaccessData(varStream.parray);
// write binary data from memory to a file. fp = fopen("Output.pdf", "wb"); if (fp != NULL) { fseek(fp, 0, SEEK_SET); fwrite(ptrDest, Size, 1, fp); fclose(fp); }
delete ptrDest;
[ASP] <HTML> <%@ Language=VBScript %> <BODY> <P> <% ' Declare variable for engine object Dim MyPDFEngine Set MyPDFEngine = CreateObject("eDocEngineX.gtPDFEngineX")
' Set the response type to PDF so the stream is loaded in the PDF viewer Response.Buffer = True Response.Clear Response.ContentType = "application/pdf" Response.AddHeader "Content-Type", "application/pdf" Response.AddHeader "content-disposition", "inline;filename=Output.pdf" With MyPDFEngine .PrefOutputToMemory = true .PrefOpenAfterCreate = false .PrefShowSetupDialog = false .BeginDoc .TextOutXY 2, 2, "Gnostice eDocEngine ActiveX" .EndDoc End With Response.BinaryWrite MyPDFEngine.GetMemoryBuffer Response.Flush set MyPDFEngine = Nothing Response.End %> </P> </BODY> </HTML>
|