Ejemplo n.º 1
0
        private void LogCreatedRootTagHasMappingIssue(PdfNamespace rootTagOriginalNs, IRoleMappingResolver mapping
                                                      )
        {
            String origRootTagNs = "";

            if (rootTagOriginalNs != null && rootTagOriginalNs.GetNamespaceName() != null)
            {
                origRootTagNs = " in \"" + rootTagOriginalNs.GetNamespaceName() + "\" namespace";
            }
            String mappingRole = " to ";

            if (mapping != null)
            {
                mappingRole += "\"" + mapping.GetRole() + "\"";
                if (mapping.GetNamespace() != null && !StandardNamespaces.PDF_1_7.Equals(mapping.GetNamespace().GetNamespaceName
                                                                                             ()))
                {
                    mappingRole += " in \"" + mapping.GetNamespace().GetNamespaceName() + "\" namespace";
                }
            }
            else
            {
                mappingRole += "not standard role";
            }
            ILog logger = LogManager.GetLogger(typeof(iText.Kernel.Pdf.Tagutils.RootTagNormalizer));

            logger.Warn(String.Format(iText.IO.LogMessageConstant.CREATED_ROOT_TAG_HAS_MAPPING, origRootTagNs, mappingRole
                                      ));
        }
Ejemplo n.º 2
0
        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);
            }
        }
        public static PdfStructureAttributes GetListAttributes(AbstractRenderer renderer, TagTreePointer taggingPointer
                                                               )
        {
            IRoleMappingResolver resolvedMapping = null;

            resolvedMapping = ResolveMappingToStandard(taggingPointer);
            if (resolvedMapping == null || !StandardRoles.L.Equals(resolvedMapping.GetRole()))
            {
                return(null);
            }
            PdfDictionary attributes = new PdfDictionary();

            attributes.Put(PdfName.O, PdfName.List);
            Object listSymbol       = renderer.GetProperty <Object>(Property.LIST_SYMBOL);
            bool   tagStructurePdf2 = IsTagStructurePdf2(resolvedMapping.GetNamespace());

            if (listSymbol is ListNumberingType)
            {
                ListNumberingType numberingType = (ListNumberingType)listSymbol;
                attributes.Put(PdfName.ListNumbering, TransformNumberingTypeToName(numberingType, tagStructurePdf2));
            }
            else
            {
                if (tagStructurePdf2)
                {
                    if (listSymbol is IListSymbolFactory)
                    {
                        attributes.Put(PdfName.ListNumbering, PdfName.Ordered);
                    }
                    else
                    {
                        attributes.Put(PdfName.ListNumbering, PdfName.Unordered);
                    }
                }
            }
            return(attributes.Size() > 1 ? new PdfStructureAttributes(attributes) : null);
        }