Disk buffering is useful for creating large PDF documents, when the impact on the available system memory needs to be reduced. By default (without enabling any Disk Buffering options) all of the information pertaining to the PDF file that is being created is all stored in memory and only when the PDF is ready to be created (with the calling of the “Draw” or “DrawToWeb” method call) is the PDF drawn out to disk. However with Disk Buffering enabled, instead of storing all that temporary information in memory until the final PDF is output, the library stores the information on the disk. This has an end result of reducing the memory usage, however the overhead of writing back and forth to the disk will have some impact (however minimal) on the overall performance.
The following code demonstrates how to enable disk buffering for a specific document:
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 at a global level for all documents:
DiskBufferingOptions.Current.Enabled = true; DiskBufferingOptions.Current.Location = "PhysicalTempFilePath";
DiskBufferingOptions.Current.Enabled = True DiskBufferingOptions.Current.Location = "PhysicalTempFilePath"