public virtual void TagTreePointerTest06() { PdfReader reader = new PdfReader(sourceFolder + "taggedDocument.pdf"); PdfWriter writer = new PdfWriter(destinationFolder + "tagTreePointerTest06.pdf"); writer.SetCompressionLevel(CompressionConstants.NO_COMPRESSION); PdfDocument document = new PdfDocument(reader, writer); TagTreePointer tagPointer = new TagTreePointer(document); tagPointer.SetRole(PdfName.Part); NUnit.Framework.Assert.AreEqual(tagPointer.GetRole().GetValue(), "Part"); tagPointer.MoveToKid(PdfName.Table).GetProperties().SetLanguage("en-US"); tagPointer.MoveToKid(PdfName.TR).MoveToKid(PdfName.TD).MoveToKid(PdfName.P); String actualText1 = "Some looong latin text"; tagPointer.GetProperties().SetActualText(actualText1); NUnit.Framework.Assert.IsNull(tagPointer.GetConnectedElement(false)); IAccessibleElement connectedElement = tagPointer.GetConnectedElement(true); tagPointer.MoveToRoot().MoveToKid(PdfName.Table).MoveToKid(1, PdfName.TR).GetProperties().SetActualText("More latin text" ); connectedElement.SetRole(PdfName.Div); connectedElement.GetAccessibilityProperties().SetLanguage("en-Us"); NUnit.Framework.Assert.AreEqual(connectedElement.GetAccessibilityProperties().GetActualText(), actualText1 ); document.Close(); CompareResult("tagTreePointerTest06.pdf", "cmp_tagTreePointerTest06.pdf", "diff06_"); }
/// <summary>Sets new role to the current tag.</summary> /// <param name="role">new role to be set.</param> /// <returns> /// this /// <see cref="TagStructureContext"/> /// instance. /// </returns> public virtual iText.Kernel.Pdf.Tagutils.TagTreePointer SetRole(PdfName role) { IAccessibleElement connectedElement = tagStructureContext.GetModelConnectedToStruct(GetCurrentStructElem() ); if (connectedElement != null) { connectedElement.SetRole(role); } else { GetCurrentStructElem().SetRole(role); } return(this); }