I have a C dll that returns a PDF file as a unsigned char* containing hex values. How do I use ctypes to retrieve this array and save it to a file 'unearthing' the PDF?
For example in C I do this:
unsigned char* manual = getPluginManualAsPDF(mPlugin);
long nrOfBytes = getPluginManualNrOfBytes(mPlugin);
string tempFile(mtk::JoinPath(getTempFolder(getRRHandleFromPlugin(mPlugin)), "AddNoisePluginDoc.pdf"));
ofstream temp(tempFile.c_str(), std::ios::binary);
long byteNr = 0;
while (byteNr < nrOfBytes)
{
temp<< manual[byteNr];
byteNr++;
}
temp.close();
//Spanw an external pdf reader
ShellExecute(Handle, "open", tempFile.c_str(), NULL, NULL,SW_SHOWNORMAL) ;
}
I am trying to access the same functions (getPluginManualAsPDF and getPluginManualNrOfBytes) via CTypes, i.e.
rrpLib.getPluginManualAsPDF.restype = c_buffer
def getPluginManualAsPDF(pluginHandle):
return rrpLib.getPluginManualAsPDF(pluginHandle)
def getPluginManualNrOfBytes(pluginHandle):
return rrpLib.getPluginManualNrOfBytes(pluginHandle)
But have problem with the return of getPluginManualAsPDF() function.. Any help appreciated.