Пример #1
0
 public static void ApplyLayoutAttributes(PdfName role, AbstractRenderer renderer, PdfDocument doc) {
     if (!(renderer.GetModelElement() is IAccessibleElement)) {
         return;
     }
     int tagType = PdfStructElem.IdentifyType(doc, role);
     PdfDictionary attributes = new PdfDictionary();
     PdfName attributesType = PdfName.Layout;
     attributes.Put(PdfName.O, attributesType);
     PdfDictionary roleMap = doc.GetStructTreeRoot().GetRoleMap();
     if (roleMap.ContainsKey(role)) {
         role = roleMap.GetAsName(role);
     }
     //TODO WritingMode attribute applying when needed
     ApplyCommonLayoutAttributes(renderer, attributes);
     if (tagType == PdfStructElem.BlockLevel) {
         ApplyBlockLevelLayoutAttributes(role, renderer, attributes, doc);
     }
     if (tagType == PdfStructElem.InlineLevel) {
         ApplyInlineLevelLayoutAttributes(renderer, attributes);
     }
     if (tagType == PdfStructElem.Illustration) {
         ApplyIllustrationLayoutAttributes(renderer, attributes);
     }
     if (attributes.Size() > 1) {
         AccessibilityProperties properties = ((IAccessibleElement)renderer.GetModelElement()).GetAccessibilityProperties
             ();
         RemoveSameAttributesTypeIfPresent(properties, attributesType);
         properties.AddAttributes(attributes);
     }
 }
Пример #2
0
 internal virtual void ThrowExceptionIfRoleIsInvalid(PdfName role)
 {
     if (forbidUnknownRoles && PdfStructElem.IdentifyType(GetDocument(), role) == PdfStructElem.Unknown)
     {
         throw new PdfException(PdfException.RoleIsNotMappedWithAnyStandardRole);
     }
 }