Disk Buffering

Disk buffering helps create large PDF documents that reduces the required available system memory. By default (without enabling any Disk Buffering options), information about a PDF being created is stored entirely in memory. Memory is only released after calling a Document class's - or MergeDocument class's - Draw method. But, with Disk Buffering enabled, DynamicPDF stores the information on disk rather than storing temporary information in memory.

The overhead of writing back and forth to the disk has some impact on overall performance, albeit much less than if storing a large document in memory.


Use the DiskBufferingOptions class to specify buffering to disk rather than memory.


The DiskBufferingOptions class has the following properties.

Property Description
Current Gets the default disk buffering options.
Enabled Gets or sets disk buffering options.
Location The location where to store the temporary file.


The following code demonstrates enabling disk buffering.

 Document document = new Document();
 DiskBufferingOptions options = new DiskBufferingOptions();
 options.Location = @"PhysicalTempFilePath";
 document.DiskBuffering = options;        
 Dim MyDocument As Document = New Document()
 Dim MyOptions As DiskBufferingOptions = New DiskBufferingOptions()
 MyOptions.Location = "PhysicalTempFilePath"
 MyDocument.DiskBuffering = MyOptions  

The following code demonstrates how to enable disk buffering globally.

DiskBufferingOptions.Current.Enabled = true;
DiskBufferingOptions.Current.Location = "PhysicalTempFilePath";        
DiskBufferingOptions.Current.Enabled = True
DiskBufferingOptions.Current.Location = "PhysicalTempFilePath"

Refer to the DiskBufferingOptions API documentation for a complete example.

In this topic