Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个基本的 C 函数,它创建一个pdf ,然后将其写入磁盘,HPDF_SaveToFile(pdf, filename)其中.pdfHPDF_Doc
HPDF_SaveToFile(pdf, filename)
pdf
HPDF_Doc
但现在我想更改函数行为,而不是写入磁盘,而是将 pdf 作为二进制返回,我将在其他地方使用它。
如何从HPDF_Doc变量中获取二进制文件?
解决了,我是这样做的:
HPDF_SaveToStream(pdf); unsigned int streamSize = HPDF_GetStreamSize(pdf); unsigned char* buffer = malloc(streamSize * sizeof(buffer)); HPDF_Stream_Read(pdf->stream, buffer, &streamSize);
这种方式buffer变量将包含二进制
buffer