Click or drag to resize
Pdf Library for .NET

PdfAccessibilityManager Class

Fixes the alternative text of the figures of an existing tagged PDF document: adds a description where one is missing, replaces a bad one (a file name, "image1"), or marks a decorative image as decorative.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfAccessibilityManager

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.6
Syntax
public class PdfAccessibilityManager : IDisposable

The PdfAccessibilityManager type exposes the following members.

Constructors
 NameDescription
Public methodPdfAccessibilityManagerInitializes a new instance of the PdfAccessibilityManager class. Call one of the Load overloads first.
Top
Properties
 NameDescription
Public propertyFiguresGets the figures of the document (its Figure and Formula elements), in reading order.
Public propertyMissingAlternateText Gets the figures that still have no description (decorative figures left out): neither alternative nor actual text, or only a placeholder - a file name ("chart1.png"), a numbered name ("image1", "Picture 3"), a GUID.
Top
Methods
 NameDescription
Public methodCloseCloses the loaded document.
Public methodDisposeReleases the loaded document, the same as Close; calling it more than once does nothing.
Public methodGetDocumentReturns the document with the figures' changes as a new PdfDocument.
Public methodLoad(Byte)Loads a tagged PDF document from a byte array.
Public methodLoad(PdfDocument)Loads an existing PdfDocument. It is not changed: the result is saved with Save(String) or obtained from GetDocument.
Public methodLoad(Stream)Loads a tagged PDF document from a stream.
Public methodLoad(String)Loads a tagged PDF document from a file.
Public methodLoad(Byte, String)Loads a password-protected tagged PDF document from a byte array.
Public methodLoad(PdfDocument, String)Loads an existing password-protected PdfDocument.
Public methodLoad(Stream, String)Loads a password-protected tagged PDF document from a stream.
Public methodLoad(String, String)Loads a password-protected tagged PDF document from a file.
Public methodSaveSaves the document with the figures' changes and returns its bytes.
Public methodSave(Stream)Saves the document with the figures' changes to a stream.
Public methodSave(String)Saves the document with the figures' changes to a file.
Top
Remarks

Missing alternative text is the most common reason a PDF fails PDF/UA (ISO 14289-1 7.3): this turns such a file into a passing one without generating it again. Figures lists the figures - the Figure and Formula elements of the structure tree, through its role map - in reading order; GetImage(Int32) renders one, for review or for a service that describes images.

Tagged documents only. An untagged document has no structure element to carry a description, and alternative text alone would not make it accessible, so Load refuses it with a message saying so.

What changes. Setting a text writes the element's /Alt (or /ActualText) and nothing else. A decorative figure leaves the structure tree and its content is marked as an artifact: the page looks the same, and screen readers skip it. A signed document is appended to, so its signatures still verify; a document that declares PDF/UA is checked again when it is saved.

Example
PdfAccessibilityManager manager = new PdfAccessibilityManager();
manager.Load("report.pdf");
foreach (PdfFigure figure in manager.MissingAlternateText)
{
    byte[] png = figure.GetImage(150);
    figure.AlternateText = Describe(png);
}
manager.Figures[3].IsDecorative = true;
manager.Save("report-fixed.pdf");
manager.Close();
See Also