How to get a byte array from PDFDoc without saving it locally?

Q:
Is there a way of getting a byte array of the PDFDoc without saving it
locally? On all the examples that I have found they only save using
pdfDoc.Save("<some path>", <Doc.SaveOptions>) but I don't want save
the file to disk.
---
A:

Simply use a version of 'PDFDoc.Save()' that accepts a byte array. For
an example of how to save a PDF to a memory buffer you may want to
take a look at PDFDocMemory sample project: