private void SetNamespaceForNewTagsBasedOnExistingRoot() { IList <IStructureNode> rootKids = document.GetStructTreeRoot().GetKids(); if (rootKids.Count > 0) { PdfStructElem firstKid = (PdfStructElem)rootKids[0]; IRoleMappingResolver resolvedMapping = ResolveMappingToStandardOrDomainSpecificRole(firstKid.GetRole().GetValue (), firstKid.GetNamespace()); if (resolvedMapping == null || !resolvedMapping.CurrentRoleIsStandard()) { ILog logger = LogManager.GetLogger(typeof(iText.Kernel.Pdf.Tagutils.TagStructureContext)); String nsStr; if (firstKid.GetNamespace() != null) { nsStr = firstKid.GetNamespace().GetNamespaceName(); } else { nsStr = StandardNamespaces.GetDefault(); } logger.Warn(String.Format(iText.IO.LogMessageConstant.EXISTING_TAG_STRUCTURE_ROOT_IS_NOT_STANDARD, firstKid .GetRole().GetValue(), nsStr)); } if (resolvedMapping == null || !StandardNamespaces.PDF_1_7.Equals(resolvedMapping.GetNamespace().GetNamespaceName ())) { documentDefaultNamespace = FetchNamespace(StandardNamespaces.PDF_2_0); } } else { documentDefaultNamespace = FetchNamespace(StandardNamespaces.PDF_2_0); } }
internal RoleMappingResolverPdf2(String role, PdfNamespace @namespace, PdfDocument document) { this.currRole = PdfStructTreeRoot.ConvertRoleToPdfName(role); this.currNamespace = @namespace; String defaultNsName = StandardNamespaces.GetDefault(); PdfDictionary defaultNsRoleMap = document.GetStructTreeRoot().GetRoleMap(); this.defaultNamespace = new PdfNamespace(defaultNsName).SetNamespaceRoleMap(defaultNsRoleMap); if (currNamespace == null) { currNamespace = defaultNamespace; } }