How do I take a PDFDoc and write the PDF that it represents to memory?

Q: I must be just missing it, but I can't find a version of the
method that just deals with memory. After I finish manipulating a
instance, I just want to get the raw data file to save in a database.
I see
the save method signature that writes to a file (and sadly, I'm
writing it to a temporary file, then reading the file, then deleting
but I'm assuming you have a version to write to memory. I even see a
signature in the documentation that I have that I can't see in .NET
intellisense that seems to pass around buffers.

How do I just take a PDFDoc and write the PDF that it represents to
(a byte[])
A: Unfortunately intellisense sometimes does not work reliably.

You can use a version of pdfdoc.Save(...) method that can save to a
memory buffer. For a concrete example please take a look at
PDFDocMemory sample project (

You can serialize PDFDoc to memory as shown in PDFDocMemory sample
project ( For

// In C#:
byte[] buf = new byte[1];
int buf_sz = 1;
doc.Save(ref buf, ref buf_sz,

// In JAVA
byte[], null);

// In C++
const char* buf = 0;
size_t buf_sz;
doc.Save(buf, buf_sz, pdftron::SDF::SDFDoc::e_linearized, 0);