public virtual void StructElemTest05() { FileStream fos = new FileStream(destinationFolder + "structElemTest05.pdf", FileMode.Create); PdfWriter writer = new PdfWriter(fos); writer.SetCompressionLevel(CompressionConstants.NO_COMPRESSION); PdfDocument document = new PdfDocument(writer); document.SetTagged(); PdfStructElem doc = document.GetStructTreeRoot().AddKid(new PdfStructElem(document, PdfName.Document)); PdfPage page = document.AddNewPage(); PdfCanvas canvas = new PdfCanvas(page); canvas.BeginText(); canvas.SetFontAndSize(PdfFontFactory.CreateFont(FontConstants.COURIER), 14); canvas.SetTextMatrix(1, 0, 0, 1, 32, 512); PdfStructElem paragraph = doc.AddKid(new PdfStructElem(document, PdfName.P)); PdfStructElem span1 = paragraph.AddKid(new PdfStructElem(document, PdfName.Span, page)); canvas.OpenTag(new CanvasTag(span1.AddKid(new PdfMcrNumber(page, span1)))); canvas.ShowText("Click "); canvas.CloseTag(); PdfStructElem link = paragraph.AddKid(new PdfStructElem(document, PdfName.Link, page)); canvas.OpenTag(new CanvasTag(link.AddKid(new PdfMcrNumber(page, link)))); canvas.SetFillColorRgb(0, 0, 1).ShowText("here"); PdfLinkAnnotation linkAnnotation = new PdfLinkAnnotation(new Rectangle(80, 508, 40, 18)); linkAnnotation.SetColor(new float[] { 0, 0, 1 }).SetBorder(new PdfArray(new float[] { 0, 0, 1 })); page.AddAnnotation(-1, linkAnnotation, false); link.AddKid(new PdfObjRef(linkAnnotation, link)); canvas.CloseTag(); PdfStructElem span2 = paragraph.AddKid(new PdfStructElem(document, PdfName.Span, page)); canvas.OpenTag(new CanvasTag(span2.AddKid(new PdfMcrNumber(page, span2)))); canvas.SetFillColorRgb(0, 0, 0); canvas.ShowText(" to visit iText site."); canvas.CloseTag(); canvas.EndText(); canvas.Release(); document.Close(); CompareResult("structElemTest05.pdf", "cmp_structElemTest05.pdf", "diff_structElem_05_"); }