Pdf | |
The PdfAccessibilityManager type exposes the following members.
| Name | Description | |
|---|---|---|
| PdfAccessibilityManager | Initializes a new instance of the PdfAccessibilityManager class. Call one of the Load overloads first. |
| Name | Description | |
|---|---|---|
| Figures | Gets the figures of the document (its Figure and Formula elements), in reading order. | |
| MissingAlternateText | 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. |
| Name | Description | |
|---|---|---|
| Close | Closes the loaded document. | |
| Dispose | Releases the loaded document, the same as Close; calling it more than once does nothing. | |
| GetDocument | Returns the document with the figures' changes as a new PdfDocument. | |
| Load(Byte) | Loads a tagged PDF document from a byte array. | |
| Load(PdfDocument) | Loads an existing PdfDocument. It is not changed: the result is saved with Save(String) or obtained from GetDocument. | |
| Load(Stream) | Loads a tagged PDF document from a stream. | |
| Load(String) | Loads a tagged PDF document from a file. | |
| Load(Byte, String) | Loads a password-protected tagged PDF document from a byte array. | |
| Load(PdfDocument, String) | Loads an existing password-protected PdfDocument. | |
| Load(Stream, String) | Loads a password-protected tagged PDF document from a stream. | |
| Load(String, String) | Loads a password-protected tagged PDF document from a file. | |
| Save | Saves the document with the figures' changes and returns its bytes. | |
| Save(Stream) | Saves the document with the figures' changes to a stream. | |
| Save(String) | Saves the document with the figures' changes to a file. |
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.
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();