Table of Contents

Class PdfAConverter

Namespace
LMKit.Document.Pdf
Assembly
LM-Kit.NET.dll

Converts an existing PDF document to the PDF/A archival format (ISO 19005), producing a self-contained file suitable for long-term preservation and legal archiving.

public static class PdfAConverter
Inheritance
PdfAConverter
Inherited Members

Examples

Example 1: Convert a PDF file to PDF/A-2b.

using LMKit.Document.Pdf;

var report = PdfAConverter.ConvertToFile("invoice.pdf", "invoice_pdfa.pdf"); Console.WriteLine($"Conforms: {report.Conforms}, fixes: {report.FixesApplied}");

Example 2: Target PDF/A-3b and fail instead of rasterizing.

using LMKit.Document.Pdf;

var options = new PdfAConversionOptions { Level = PdfAConformanceLevel.PdfA3b, Fallback = PdfAConversionOptions.FallbackBehavior.Fail };

var report = await PdfAConverter.ConvertToFileAsync("contract.pdf", "contract_pdfa.pdf", options);

Example 3: Convert in memory.

using LMKit.Document.Pdf;

byte[] source = await httpClient.GetByteArrayAsync("https://example.com/report.pdf"); var result = PdfAConverter.ConvertToBytes(source); await File.WriteAllBytesAsync("report_pdfa.pdf", result.Data);

Remarks

Conversion strategy. The converter first repairs the document in place: prohibited constructs are removed (JavaScript, launch actions, encryption, external references), non-embedded fonts are replaced by embedded equivalents with reconciled metrics, prohibited compression is re-encoded, device colour spaces are calibrated through embedded ICC profiles, and content streams are normalized. The repaired document is then rewritten with PDF/A identification metadata, an sRGB output intent, and XMP metadata mirrored from the document information dictionary. Text, vector graphics, and layout are preserved.

Raster fallback. When the document carries violations the rewrite cannot repair, the behavior is governed by Fallback. The default, Rasterize, guarantees a conforming output by rebuilding the affected document from rendered page images, overlaid with an invisible text layer so the result stays searchable. Fail throws instead, and ReportOnly produces the best-effort rewrite and lists the remaining violations in the report.

Conformance levels. PDF/A-1b, PDF/A-2b and PDF/A-3b are supported through Level; the default is PdfA2b, the level most archives request. Encrypted sources are supported by passing Password; the output is always unencrypted, as the standard requires.

Input modes. File paths, raw bytes, streams and pre-built Attachment objects are accepted. Every input mode ships with ConvertToFile, ConvertToStream and ConvertToBytes variants, each with a synchronous and an asynchronous form. All variants return a PdfAConversionReport describing what was detected, what was repaired, and how the output was produced.

Methods

ConvertToBytes(Attachment, PdfAConversionOptions, CancellationToken)

Converts the PDF carried by attachment to PDF/A and returns the converted bytes together with the report.

ConvertToBytes(byte[], PdfAConversionOptions, CancellationToken)

Converts in-memory PDF bytes to PDF/A and returns the converted bytes together with the conversion report.

ConvertToBytes(Stream, PdfAConversionOptions, CancellationToken)

Converts the PDF read from inputStream to PDF/A and returns the converted bytes together with the report.

ConvertToBytes(string, PdfAConversionOptions, CancellationToken)

Converts the PDF at inputPath to PDF/A and returns the converted bytes together with the conversion report.

ConvertToBytesAsync(Attachment, PdfAConversionOptions, CancellationToken)

Asynchronously converts the PDF carried by attachment to PDF/A and returns the converted bytes together with the report.

ConvertToBytesAsync(byte[], PdfAConversionOptions, CancellationToken)

Asynchronously converts in-memory PDF bytes to PDF/A and returns the converted bytes together with the conversion report.

ConvertToBytesAsync(Stream, PdfAConversionOptions, CancellationToken)

Asynchronously converts the PDF read from inputStream to PDF/A and returns the converted bytes together with the report.

ConvertToBytesAsync(string, PdfAConversionOptions, CancellationToken)

Asynchronously converts the PDF at inputPath to PDF/A and returns the converted bytes together with the report.

ConvertToFile(Attachment, string, PdfAConversionOptions, CancellationToken)

Converts the PDF carried by attachment to PDF/A and writes the result to outputPath.

ConvertToFile(byte[], string, PdfAConversionOptions, CancellationToken)

Converts in-memory PDF bytes to PDF/A and writes the result to outputPath.

ConvertToFile(Stream, string, PdfAConversionOptions, CancellationToken)

Converts the PDF read from inputStream to PDF/A and writes the result to outputPath.

ConvertToFile(string, string, PdfAConversionOptions, CancellationToken)

Converts the PDF at inputPath to PDF/A and writes the result to outputPath.

ConvertToFileAsync(Attachment, string, PdfAConversionOptions, CancellationToken)

Asynchronously converts the PDF carried by attachment to PDF/A and writes the result to outputPath.

ConvertToFileAsync(byte[], string, PdfAConversionOptions, CancellationToken)

Asynchronously converts in-memory PDF bytes to PDF/A and writes the result to outputPath.

ConvertToFileAsync(Stream, string, PdfAConversionOptions, CancellationToken)

Asynchronously converts the PDF read from inputStream to PDF/A and writes the result to outputPath.

ConvertToFileAsync(string, string, PdfAConversionOptions, CancellationToken)

Asynchronously converts the PDF at inputPath to PDF/A and writes the result to outputPath.

ConvertToStream(Attachment, Stream, PdfAConversionOptions, CancellationToken)

Converts the PDF carried by attachment to PDF/A and writes the result to outputStream.

ConvertToStream(byte[], Stream, PdfAConversionOptions, CancellationToken)

Converts in-memory PDF bytes to PDF/A and writes the result to outputStream.

ConvertToStream(Stream, Stream, PdfAConversionOptions, CancellationToken)

Converts the PDF read from inputStream to PDF/A and writes the result to outputStream.

ConvertToStream(string, Stream, PdfAConversionOptions, CancellationToken)

Converts the PDF at inputPath to PDF/A and writes the result to outputStream.

ConvertToStreamAsync(Attachment, Stream, PdfAConversionOptions, CancellationToken)

Asynchronously converts the PDF carried by attachment to PDF/A and writes the result to outputStream.

ConvertToStreamAsync(byte[], Stream, PdfAConversionOptions, CancellationToken)

Asynchronously converts in-memory PDF bytes to PDF/A and writes the result to outputStream.

ConvertToStreamAsync(Stream, Stream, PdfAConversionOptions, CancellationToken)

Asynchronously converts the PDF read from inputStream to PDF/A and writes the result to outputStream.

ConvertToStreamAsync(string, Stream, PdfAConversionOptions, CancellationToken)

Asynchronously converts the PDF at inputPath to PDF/A and writes the result to outputStream.

Share