Skip to main content
Version: Version 1.14

.NET technical notes

Learn about specifics of the .NET interface of the Toolbox add-on.

tip

For the full API reference for the Toolbox add-on, see the .NET API reference.

IDisposable objects​

Objects that must be closed explicitly (for example, PdfTools.Toolbox.Pdf.Document or PdfTools.Toolbox.Pdf.Content.ContentGenerator) implement the IDisposable interface. Instead of calling Dispose() directly, use the using statement:

using (Document document = ...)
{
...
}
// document.Dispose() is called implicitly here

Error handling​

Errors are reported using exceptions. Where applicable, the Toolbox add-on maps errors to corresponding native exception classes, such as System.ArgumentException, System.InvalidOperationException, System.NotSupportedException, or System.IO.IOException. The remaining errors are modeled using exception classes that inherit from a base class PdfToolsException.

Streams​

The native stream interface System.IO.Stream is used.

Lists and iterables​

The API uses different concepts for returning collections of elements depending on the context:

  • Lists (System.Collections.Generic.IList<T>) are used when the elements are already in memory and random access is possible. Depending on the context, manipulation (add, remove, and so on) might also be possible.
  • Iterables (System.Collections.Generic.IEnumerable<T>) are used when elements are retrieved on demand. They don’t allow random access, but only allow iterating through the elements.

Maps​

Maps implement the native dictionary interface System.Collections.Generic.IDictionary<K, V>.

Namespace​

The Toolbox add-on uses the namespace PdfTools.Toolbox.

note

We recommend using a custom, company-specific namespace for your code. Using the PdfTools.Toolbox namespace like the Toolbox add-on can lead to problems with ambiguous class names.