I’m required to create links in a specific way for accessibility needs. Below is the function I have so far that is working correctly to a point:
Public Sub FindPDFText(searchText As String, pagenum As Integer, strFileName As String)
Dim doc As New Aspose.Pdf.Document(strFileName)
Dim textFragmentAbsorber As New Aspose.Pdf.Text.TextFragmentAbsorber(searchText)
doc.Pages.Accept(textFragmentAbsorber)
Dim textFragments As Aspose.Pdf.Text.TextFragmentCollection = textFragmentAbsorber.TextFragments
For Each textFragment As Aspose.Pdf.Text.TextFragment In textFragments
Dim link As New Aspose.Pdf.Annotations.LinkAnnotation(textFragment.Page, textFragment.Rectangle)
link.Action = New Aspose.Pdf.Annotations.GoToAction(doc.Pages(pagenum))
' Add the link annotation to the page's annotations collection
textFragment.Page.Annotations.Add(link)
Next
End Sub
This creates a tag type Container, structure tag=paragraph and looks like below.
image.png (2.0 KB)
What the accessibility needs to be structured like is as follows.
image.png (4.3 KB)
It starts with the Link with the following properties:
Type: Annotation, Sctructure Tag: Link, Type: Link, Alternative Text: Call to Order and Roll Call 5"
The next tag “Call to Order and Roll Call 5” is as follows:
Type: Container, Container Tag: Link, Structure Tag: Link, Type: Link, Alternative Text: Call to Order and Roll CAll 5"
And then finally the Link - OBJR is as follows:
Type: Annotation, Structure Tag: Link, Type: Link, Alternative Text “Call to ORder and Roll CAll 5”
So with the code I have above, is there any way I can modify it to develop the tag structure shown above?