private static void ApplyInlineLevelLayoutAttributes(AbstractRenderer renderer, PdfDictionary attributes) { float? textRise = renderer.GetPropertyAsFloat(Property.TEXT_RISE); if (textRise != null && textRise != 0) { attributes.Put(PdfName.BaselineShift, new PdfNumber((float)textRise)); } Object underlines = renderer.GetProperty<Object>(Property.UNDERLINE); if (underlines != null) { float? fontSize = renderer.GetPropertyAsFloat(Property.FONT_SIZE); Underline underline = null; if (underlines is IList && !((IList<Object>)underlines).IsEmpty() && ((IList)underlines)[0] is Underline) { // in standard attributes only one text decoration could be described for an element. That's why we take only the first underline from the list. underline = (Underline)((IList)underlines)[0]; } else { if (underlines is Underline) { underline = (Underline)underlines; } } if (underline != null) { attributes.Put(PdfName.TextDecorationType, underline.GetYPosition((float)fontSize) > 0 ? PdfName.LineThrough : PdfName.Underline); if (underline.GetColor() is DeviceRgb) { attributes.Put(PdfName.TextDecorationColor, new PdfArray(underline.GetColor().GetColorValue())); } attributes.Put(PdfName.TextDecorationThickness, new PdfNumber(underline.GetThickness((float)fontSize))); } } }
private static void ApplyInlineLevelLayoutAttributes(AbstractRenderer renderer, PdfDictionary attributes) { float?textRise = renderer.GetPropertyAsFloat(Property.TEXT_RISE); if (textRise != null && textRise != 0) { attributes.Put(PdfName.BaselineShift, new PdfNumber((float)textRise)); } Object underlines = renderer.GetProperty <Object>(Property.UNDERLINE); if (underlines != null) { UnitValue fontSize = renderer.GetPropertyAsUnitValue(Property.FONT_SIZE); if (!fontSize.IsPointValue()) { ILog logger = LogManager.GetLogger(typeof(AccessibleAttributesApplier)); logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property .FONT_SIZE)); } Underline underline = null; if (underlines is IList && ((IList)underlines).Count > 0 && ((IList)underlines)[0] is Underline) { // in standard attributes only one text decoration could be described for an element. That's why we take only the first underline from the list. underline = (Underline)((IList)underlines)[0]; } else { if (underlines is Underline) { underline = (Underline)underlines; } } if (underline != null) { attributes.Put(PdfName.TextDecorationType, underline.GetYPosition(fontSize.GetValue()) > 0 ? PdfName.LineThrough : PdfName.Underline); if (underline.GetColor() is DeviceRgb) { attributes.Put(PdfName.TextDecorationColor, new PdfArray(underline.GetColor().GetColorValue())); } attributes.Put(PdfName.TextDecorationThickness, new PdfNumber(underline.GetThickness(fontSize.GetValue())) ); } } }