virtual public void SetAccessibleAttribute(PdfName key, PdfObject value) { title.SetAccessibleAttribute(key, value); }
public virtual void CreateTaggedPdf24() { Document document = new Document(PageSize.LETTER); MemoryStream baos = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, baos); writer.ViewerPreferences = PdfWriter.DisplayDocTitle; //set more document properties writer.PdfVersion = PdfWriter.VERSION_1_7; writer.SetTagged(PdfWriter.markInlineElementsOnly); PdfDictionary info = writer.Info; info.Put(PdfName.TITLE, new PdfString("Testing")); writer.CreateXmpMetadata(); // step 3 document.Open(); document.AddLanguage("en_US"); document.SetAccessibleAttribute(PdfName.LANG, new PdfString("en_US")); // step 4 Paragraph p = new Paragraph("Paragraph testing testing"); p.SetAccessibleAttribute(PdfName.ACTUALTEXT, new PdfString("Paragraph ALT Text")); p.SetAccessibleAttribute(PdfName.ALT, new PdfString("Paragraph ALT Text")); document.Add(p); Chunk ck = new Chunk("Span testing testing", FontFactory.GetFont(RESOURCES + @"..\FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 12)); ck.SetAccessibleAttribute(PdfName.ACTUALTEXT, new PdfString("Span ALT Text")); ck.SetAccessibleAttribute(PdfName.ALT, new PdfString("Span ALT Text")); p = new Paragraph(ck); document.Add(p); // step 5 document.Close(); FileStream fos = new FileStream("TaggedPdfTest/pdf/out24.pdf", FileMode.Create); byte[] buff = baos.ToArray(); fos.Write(buff, 0, buff.Length); fos.Flush(); fos.Close(); CompareResults("24"); }