Pdf Tools SDK for .NET
The Pdf Tools SDK for .NET lets you create PDF files using .NET.
The Pdf Tools SDK for .NET uses the .NET Standard version 2.0.
For the full API reference for the Pdf Tools SDK, see the .NET API reference.
IDisposable objects
Objects that must be closed explicitly (e.g. PdfTools.Pdf.Document
, PdfTools.Image.Document
, PdfTools.Crypto.Providers.Provider
, or sub-classes) implement the IDisposable
interface. Instead of calling Dispose()
directly, it is recommended that you use the “using” statement:
using (Document document = ...)
{
...
}
// document.Dispose() is called implicitly here
Error handling
Errors are reported using exceptions.
Where applicable, the SDK 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 & Iterables
The API uses different concepts for returning collections of elements depending on the context:
- lists (
System.Collections.Generic.IList<T>
) are usually used when the elements are already in memory and random access is possible. Depending on the context manipulation (add, remove, etc.) might also be possible. - iterables (
System.Collection.Generic.IEnumerable<T>
) are usually used, when elements are retrieved on demand. They do not allow random access, but instead only allow iterating through the elements.
Maps
Maps implement the native dictionary interface System.Collections.Generic.IDictionary<K, V>
.
Namespace
The Pdf Tools SDK uses the namespace PdfTools
.
We recommend to use a custom, company specific namespace for your code.
Using the PdfTools
namespace like the SDK can lead to problems with ambiguous class names, especially when using multiple of our SDKs in the same project.