Skip to main content
Version: 1.3

Convert an image to an accessible PDF

Valid PDF/A documents with A-level (Accessibility) conformance (PDF/A-1a, PDF/A-2a, PDF/A-3a) must have text that can be reliably searched and copied. The content structure in the accessible PDF/A document can be accessed by technologies such as screen readers.

Quick start

Download the full sample now in C# and Java.

Interested in C or other language samples? Let us know on the contact page and we'll add it to our samples backlog.

When converting an image to a PDF/A document with A-level conformance, descriptive text must be provided for each page that is added to the document. For example, "This color image shows a small sailing boat at sunset". The language of the text must also be provided in ISO 3166:2013 format. For example, "en" or "de-CH".

For scanned text documents, the Conversion Service can be used to recognize the characters in the documents (OCR) and tag the image with the recognized structure and text.

tip

For more background about converting images to PDF documents, see Convert an image to a PDF document.

Steps to convert a document

  1. Reading the input image
  2. Selecting a conversion profile
  3. Specifying the conformance level
  4. Adding accessible content
  5. Converting the image to a PDF document
  6. Full example

Before you begin

Reading the input image

First you need to read the image you want to convert. To do this, load the input image from the file system into a read-only image Document. This Document can then later be passed to the Converter.

// Open image document
using var inStr = File.OpenRead(inPath);
using var inDoc = Document.Open(inStr);

Selecting a conversion profile

You start the image conversion process by creating a conversion Profile object. The Profile object defines the parameters that are applied to the conversion process.

This example uses the Archive profile, which is intended for document workflows that convert images to PDF/A documents for archiving.

/// Create the profile that defines the conversion parameters.
// The Archive profile converts images to PDF/A documents for archiving.

var profile = new Profiles.Archive();

Specifying the conformance level

By default, the Archive profile produces output PDF documents with PDF/A-2b conformance. If the document workflow requires accessible content to be included in the output PDF, then conformance Level A (Accessible) should be used instead.

This examples sets the document conformance to PDF/A-2a.

// Set conformance of output document to PDF/A-2a
profile.Conformance = new Conformance(2, Conformance.PdfALevel.A);

Adding accessible content

For each page created in the output PDF/A document, alternate text must be added that represents the contents of the image on that page. In addition, the language of the text should be specified at a document level.

// For PDF/A level 2a, an alternate text is required for each page of the image.
// This is optional for other PDF/A levels, e.g. PDF/A-2b.
profile.Language = "en";
profile.AlternateText.Add(alternateText);

Converting the image to a PDF document

After setting the appropriate Profile and Conformance levels, and adding accessible content, the final step is to instantiate a Converter object and call its Convert method. The output PDF/A document is created at the specified path.

// Create output stream
using var outStr = File.Create(outPath);

// Convert the image to a tagged PDF/A document
using var outDoc = new Converter().Convert(inDoc, outStr, profile);

Full example

// Open image document
using var inStr = File.OpenRead(inPath);
using var inDoc = Document.Open(inStr);

// Create the profile that defines the conversion parameters.
// The Archive profile converts images to PDF/A documents for archiving.
var profile = new Profiles.Archive();

// Set conformance of output document to PDF/A-2a
profile.Conformance = new Conformance(2, Conformance.PdfALevel.A);

// For PDF/A level 2a, an alternate text is required for each page of the image.
// This is optional for other PDF/A levels, e.g. PDF/A-2b.
profile.Language = "en";
profile.AlternateText.Add(alternateText);

// Create output stream
using var outStr = File.Create(outPath);

// Convert the image to a tagged PDF/A document
using var outDoc = new Converter().Convert(inDoc, outStr, profile);