Memory buffering vs disk writing when creating or modifying PDF files.

Q: When creating a PDF is the entire pdf document buffered in memory
or buffered on disk until the PDFDoc.Save() method is called?

If it is buffered to memory until the PDFDoc.Save() method is called,
is there a way to buffer and append each page to disk instead of in
memory? I assume that the example below will create a PDF and append
each page to the file on disk while only keeping only the current page
buffered in memory versus the whole PDF document in memory. Is my
assumption correct?

using (PDFDoc pdfDocument = new PDFDoc(outputPath)) using
(ElementBuilder builder = new ElementBuilder()) using (ElementWriter
writer = new ElementWriter()) {
    Page page = null;
    Image pdfImage = null;
    Element element = null;

    foreach (Item item in items)
    {
        if (item.IsImage)
        {
            using (System.Drawing.Bitmap bitmap = new
System.Drawing.Bitmap(item.Data))
            {
                float h = bitmap.Height / bitmap.HorizontalResolution
* 72;
                float w = bitmap.Width / bitmap.VerticalResolution *
72;

                page = pdfDocument.PageCreate(new Rect(0, 0, w, h));
                writer.Begin(page);
                pdfImage = Image.Create(pdfDocument, bitmap,
JBig2Hint);
                element = builder.CreateImage(pdfImage, new
Matrix2D(page.GetPageWidth(), 0, 0, page.GetPageHeight(), 0, 0));
                writer.WriteElement(element);
                writer.End();
                pdfDocument.PagePushBack(page);
                pdfDocument.Save(outputPath,
SDFDoc.SaveOptions.e_linearized);
            }
        }
    }
    pdfDocument.Close();
-------------------------

A: PDFNet by default writes all dynamically created content to a
temporary file (the location of which can be changed using
PDFNet.SetTempPath() ). This allows for creation huge documents
without much RAM usage.

If you would rather buffer the entire document in memory without any
temp files simply call PDFNet.SetDefaultDiskCachingEnabled(false)
after initializing PDFNet.