public virtual TagTreePointer UseAutoTaggingPointerAndRememberItsPosition(IRenderer renderer) { TagTreePointer autoTaggingPointer = context.GetAutoTaggingPointer(); TagTreePointer position = new TagTreePointer(autoTaggingPointer); autoTaggingPointerSavedPosition.Put(renderer, position); return(autoTaggingPointer); }
public virtual void CustomRolesMappingPdf2() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(destinationFolder + "customRolesMappingPdf2.pdf", new WriterProperties().SetPdfVersion(PdfVersion.PDF_2_0))); pdfDocument.SetTagged(); TagStructureContext tagsContext = pdfDocument.GetTagStructureContext(); PdfNamespace stdNamespace2 = tagsContext.FetchNamespace(StandardNamespaces.PDF_2_0); PdfNamespace xhtmlNs = new PdfNamespace("http://www.w3.org/1999/xhtml"); PdfNamespace html4Ns = new PdfNamespace("http://www.w3.org/TR/html4"); String h9 = "H9"; String h11 = "H11"; // deliberately mapping to H9 tag xhtmlNs.AddNamespaceRoleMapping(LayoutTaggingPdf2Test.HtmlRoles.h1, h9, stdNamespace2); xhtmlNs.AddNamespaceRoleMapping(LayoutTaggingPdf2Test.HtmlRoles.p, StandardRoles.P, stdNamespace2); xhtmlNs.AddNamespaceRoleMapping(LayoutTaggingPdf2Test.HtmlRoles.img, StandardRoles.FIGURE, stdNamespace2); xhtmlNs.AddNamespaceRoleMapping(LayoutTaggingPdf2Test.HtmlRoles.ul, StandardRoles.L, stdNamespace2); xhtmlNs.AddNamespaceRoleMapping(StandardRoles.SPAN, LayoutTaggingPdf2Test.HtmlRoles.span, xhtmlNs); xhtmlNs.AddNamespaceRoleMapping(LayoutTaggingPdf2Test.HtmlRoles.span, StandardRoles.SPAN, stdNamespace2); xhtmlNs.AddNamespaceRoleMapping(LayoutTaggingPdf2Test.HtmlRoles.center, StandardRoles.P, stdNamespace2); html4Ns.AddNamespaceRoleMapping(LayoutTaggingPdf2Test.HtmlRoles.center, LayoutTaggingPdf2Test.HtmlRoles.center , xhtmlNs); // test some tricky mapping cases stdNamespace2.AddNamespaceRoleMapping(h9, h11, stdNamespace2); stdNamespace2.AddNamespaceRoleMapping(h11, h11, stdNamespace2); tagsContext.GetAutoTaggingPointer().SetNamespaceForNewTags(xhtmlNs); Document document = new Document(pdfDocument); AddContentToDocInCustomNs(pdfDocument, stdNamespace2, xhtmlNs, html4Ns, h11, document); document.Close(); CompareResult("customRolesMappingPdf2"); }