当前位置: 首页>>代码示例>>C#>>正文


C# Chunk.setLineHeight方法代码示例

本文整理汇总了C#中iTextSharp.text.Chunk.setLineHeight方法的典型用法代码示例。如果您正苦于以下问题:C# Chunk.setLineHeight方法的具体用法?C# Chunk.setLineHeight怎么用?C# Chunk.setLineHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在iTextSharp.text.Chunk的用法示例。


在下文中一共展示了Chunk.setLineHeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddText

        private float AddText(string[] chunks, iTextSharp.text.Font font, float spacingBefore, float spacingAfter, int alignment, float lineHightMultiplier, Document doc)
        {
            int count = 0;
            float height = 0;
            var paragraph = new Paragraph();
            float fontSize = font.Size * lineHightMultiplier;
            var phrase = new Phrase();

            foreach(string item in chunks)
            {
                if (string.IsNullOrEmpty(item)) continue;
                var chunk = new Chunk(item + Environment.NewLine, font);
                chunk.setLineHeight(fontSize);
                phrase.Add(chunk);
                count++;
            }

            if (count > 0)
            {
                paragraph.Add(phrase);
                paragraph.Alignment = alignment;
                paragraph.SpacingBefore = spacingBefore;
                paragraph.SpacingAfter = spacingAfter;
                doc.Add(paragraph);
                height = spacingBefore + spacingAfter + count * fontSize;
            }

            return height;
        }
开发者ID:tsigdel-idc,项目名称:oracle-paas-2015,代码行数:29,代码来源:PdfReport.cs

示例2: Apply

        /**
         *
         * @param c the Chunk to apply CSS to.
         * @param t the tag containing the chunk data
         * @return the styled chunk
         */

        virtual public Chunk Apply(Chunk c, Tag t)
        {
            Font f = ApplyFontStyles(t);
            float size = f.Size;
            String value = null;
            IDictionary<String, String> rules = t.CSS;
            foreach (KeyValuePair<String, String> entry in rules)
            {
                String key = entry.Key;
                value = entry.Value;
                if (Util.EqualsIgnoreCase(CSS.Property.FONT_STYLE, key)) {
                    if (Util.EqualsIgnoreCase(CSS.Value.OBLIQUE, value)) {
                        c.SetSkew(0, 12);
                    }
                } else if (Util.EqualsIgnoreCase(CSS.Property.LETTER_SPACING, key)) {
                    String letterSpacing = entry.Value;
                    float letterSpacingValue = 0f;
                    if (utils.IsRelativeValue(value)) {
                        letterSpacingValue = utils.ParseRelativeValue(letterSpacing, f.Size);
                    } else if (utils.IsMetricValue(value)) {
                        letterSpacingValue = utils.ParsePxInCmMmPcToPt(letterSpacing);
                    }
                    c.SetCharacterSpacing(letterSpacingValue);
                } else if (Util.EqualsIgnoreCase(CSS.Property.XFA_FONT_HORIZONTAL_SCALE, key)) {
                    // only % allowed; need a catch block NumberFormatExc?
                    c.SetHorizontalScaling(
                        float.Parse(value.Replace("%", ""))/100);
                }
            }
            // following styles are separate from the for each loop, because they are based on font settings like size.
            if (rules.TryGetValue(CSS.Property.VERTICAL_ALIGN, out value))
            {
                if (Util.EqualsIgnoreCase(CSS.Value.SUPER, value)
                    || Util.EqualsIgnoreCase(CSS.Value.TOP, value)
                    || Util.EqualsIgnoreCase(CSS.Value.TEXT_TOP, value)) {
                    c.SetTextRise((float) (size/2 + 0.5));
                } else if (Util.EqualsIgnoreCase(CSS.Value.SUB, value)
                    || Util.EqualsIgnoreCase(CSS.Value.BOTTOM, value)
                    || Util.EqualsIgnoreCase(CSS.Value.TEXT_BOTTOM, value)) {
                    c.SetTextRise(-size/2);
                } else {
                    c.SetTextRise(utils.ParsePxInCmMmPcToPt(value));
                }
            }
            String xfaVertScale;
            if (rules.TryGetValue(CSS.Property.XFA_FONT_VERTICAL_SCALE, out xfaVertScale))
            {
                if (xfaVertScale.Contains("%"))
                {
                    size *= float.Parse(xfaVertScale.Replace("%", ""))/100;
                    c.SetHorizontalScaling(100/float.Parse(xfaVertScale.Replace("%", "")));
                }
            }
            if (rules.TryGetValue(CSS.Property.TEXT_DECORATION, out value)) {
                String[] splitValues = new Regex(@"\s+").Split(value);
                foreach (String curValue in splitValues) {
                    if (Util.EqualsIgnoreCase(CSS.Value.UNDERLINE, curValue)) {
                        c.SetUnderline(0.75f, -size/8f);
                    }
                    if (Util.EqualsIgnoreCase(CSS.Value.LINE_THROUGH, curValue)) {
                        c.SetUnderline(0.75f, size/4f);
                    }
                }
            }
            if (rules.TryGetValue(CSS.Property.BACKGROUND_COLOR, out value))
            {
                c.SetBackground(HtmlUtilities.DecodeColor(value));
            }
            f.Size = size;
            c.Font = f;


            float? leading = null;
            value = null;
            if (rules.TryGetValue(CSS.Property.LINE_HEIGHT, out value)) {
                if (utils.IsNumericValue(value)) {
                    leading = float.Parse(value) * c.Font.Size;
                } else if (utils.IsRelativeValue(value)) {
                    leading = utils.ParseRelativeValue(value, c.Font.Size);
                } else if (utils.IsMetricValue(value)) {
                    leading = utils.ParsePxInCmMmPcToPt(value);
                }
            }

            if (leading != null) {
                c.setLineHeight((float)leading);
            }
            return c;
        }
开发者ID:htlp,项目名称:itextsharp,代码行数:96,代码来源:ChunkCssApplier.cs

示例3: AddList

        private float AddList(string[] chunks, iTextSharp.text.Font font, float spacingBefore, float spacingAfter, float spacingBetween, int alignment, float lineHightMultiplier, string listSymbol, int padding, float indentationLeft, Document doc)
        {
            int count = 0;
            float height = 0;
            float fontSize = font.Size * lineHightMultiplier;
            var paragraph = new Paragraph();

            var list = new List(List.UNORDERED);
            list.SetListSymbol(listSymbol.PadRight(padding));
            list.IndentationLeft = indentationLeft;

            foreach (string item in chunks)
            {
                if (string.IsNullOrEmpty(item)) continue;
                var chunk = new Chunk(item, font);
                chunk.setLineHeight(font.Size * lineHightMultiplier);
                var listItem = new ListItem(chunk);
                listItem.SpacingBefore = spacingBetween;
                list.Add(listItem);
                count++;
            }

            if (count > 0)
            {
                paragraph.Add(list);
                paragraph.Alignment = alignment;
                paragraph.SpacingBefore = spacingBefore;
                paragraph.SpacingAfter = spacingAfter;
                doc.Add(paragraph);
                height = spacingBefore + spacingAfter + count * (fontSize + spacingBetween) - spacingBetween;
            }

            return height;
        }
开发者ID:tsigdel-idc,项目名称:oracle-paas-2015,代码行数:34,代码来源:PdfReport.cs


注:本文中的iTextSharp.text.Chunk.setLineHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。