Aspose.PDF for .NET Plugins

Aspose.PDF for .NET plugins

Aspose.PDF for .NET plugins provide a task-oriented API for common PDF workflows. They are available in the Aspose.Pdf.LowCode namespace and are useful when you need to complete a document operation with a compact, repeatable sequence of steps.

Plugins are also a licensing option for applications that need only one or several specific PDF capabilities. Instead of licensing the full Aspose.PDF product family for a narrow workflow, you can license individual plugins for the operations your application uses. If your application needs broad access to the complete Aspose.PDF API surface, license the full Aspose.PDF product; a full product license also lets you use the LowCode plugin APIs.

For plugin availability and licensing options, see Aspose plugin pricing. For full product licensing, see Aspose.PDF Product Family pricing.

A plugin workflow usually contains four parts:

  1. A plugin class, such as Merger, Splitter, Html, or PdfAConverter.
  2. An options class that describes the operation, such as MergeOptions, SplitOptions, or PdfToHtmlOptions.
  3. One or more input data sources, such as FileDataSource or StreamDataSource.
  4. Optional output data sources and a ResultContainer returned by the Process method.

Use plugins when your task matches one of the supported operations: merge PDF files, split pages, convert PDF documents, optimize file size, extract text or images, process forms, sign or encrypt documents, validate PDF/A compliance, or generate common document structures.

Use the regular Aspose.PDF object model when you need detailed control over pages, annotations, text fragments, layout objects, or other low-level document elements.

Basic usage pattern

The following example merges two PDF documents by using the Merger plugin.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void MergeDocumentsWithPlugin()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Pages();

    // Create PDF Merger plugin
    var plugin = new Aspose.Pdf.LowCode.Merger();

    // Add input and output files
    var options = new Aspose.Pdf.LowCode.MergeOptions();
    options.AddInput(new Aspose.Pdf.LowCode.FileDataSource(dataDir + "Concat1.pdf"));
    options.AddInput(new Aspose.Pdf.LowCode.FileDataSource(dataDir + "Concat2.pdf"));
    options.AddOutput(new Aspose.Pdf.LowCode.FileDataSource(dataDir + "MergeDocuments_out.pdf"));

    // Process the files
    var result = plugin.Process(options);

    // Get the path of the saved file
    var outputPath = result.ResultCollection[0].ToFile();
}

The same structure is used by other plugins: create the plugin, configure options, add input and output sources, and call Process.

File and stream data sources

Plugins can work with files and streams.

  • Use FileDataSource when the input or output is stored on disk.
  • Use StreamDataSource when the input or output is already available as a stream, for example in a web application or service.

The following example splits a PDF document and writes the first result to a stream.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void SplitDocumentToStreamWithPlugin()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Pages();

    // Create PDF Splitter plugin
    var plugin = new Aspose.Pdf.LowCode.Splitter();

    // Open input and output streams
    using (var inputStream = System.IO.File.OpenRead(dataDir + "SplitToPages.pdf"))
    {
        using (var outputStream = new System.IO.MemoryStream())
        {
            // Add stream input and output
            var options = new Aspose.Pdf.LowCode.SplitOptions();
            // Keep streams open because they are disposed by the using blocks
            options.CloseInputStreams = false;
            options.CloseOutputStreams = false;
            options.AddInput(new Aspose.Pdf.LowCode.StreamDataSource(inputStream));
            options.AddOutput(new Aspose.Pdf.LowCode.StreamDataSource(outputStream));

            // Process the stream
            var result = plugin.Process(options);
        }
    }
}

Working with results

The Process method returns a ResultContainer. The container includes a ResultCollection, where each item represents an operation result.

Depending on the plugin and options, a result can be a file, stream, or string value. Use the result properties and methods to read the output:

  • IsFile indicates that the result is a file.
  • IsStream indicates that the result is a stream.
  • IsString indicates that the result is a string value.
  • ToFile() returns the output file path.
  • ToStream() returns the output stream.
  • Data returns the raw result data.

Available plugin documentation

Plugin class Documentation Main options
Merger Merger MergeOptions
Splitter Splitter SplitOptions
Optimizer Optimizer CompressOptions, OptimizeOptions, ResizeOptions, RotateOptions
DocConverter DocConverter PdfToDocOptions
Html Html PdfToHtmlOptions, HtmlToPdfOptions
XlsConverter XlsConverter PdfToXlsOptions
Ofd Ofd OfdToPdfOptions
Jpeg Jpeg JpegOptions
Png Png PngOptions
Tiff Tiff TiffOptions
PdfAConverter PdfAConverter PdfAConvertOptions, PdfAValidateOptions
TextExtractor TextExtractor TextExtractorOptions
ImageExtractor ImageExtractor ImageExtractorOptions
FormEditor FormEditor FormEditorAddOptions, FormEditorSetOptions, remove options
FormImporter FormImporter FormImporterJsonOptions
FormExporter FormExporter FormExporterToJsonOptions, FormExporterValuesToCsvOptions
FormFlattener FormFlattener FormFlattenAllFieldsOptions, FormFlattenSelectedFieldsOptions
Security Security EncryptionOptions, DecryptionOptions
Signature Signature SignOptions
Timestamp Timestamp TimestampOptions
TableGenerator TableGenerator TableOptions
TocGenerator TocGenerator TocOptions

Choosing a plugin

Choose the plugin that represents the operation you want to perform, and then select the matching options class. For example, use Merger with MergeOptions to merge files, Html with PdfToHtmlOptions to convert PDF to HTML, and PdfAConverter with PdfAValidateOptions to validate PDF/A compliance.

When you write production code, configure all required input and output data sources explicitly. Check the returned ResultContainer before using the output, especially when a workflow can produce multiple files or values.