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


C# Chunk.GetImage方法代码示例

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


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

示例1: WriteAttributes

        private void WriteAttributes(Chunk chunk)
        {
            if (chunk != null)
            {
                if (chunk.GetImage() != null)
                    WriteAttributes(chunk.GetImage());
                else
                {
                    Dictionary<String, Object> attr = chunk.Attributes;
                    if (attr != null)
                    {
                        // Setting non-inheritable attributes
                        if (attr.ContainsKey(Chunk.UNDERLINE))
                            this.SetAttribute(PdfName.TEXTDECORATIONTYPE, PdfName.UNDERLINE);
                        if (attr.ContainsKey(Chunk.BACKGROUND))
                        {
                            Object[] back = (Object[]) attr[Chunk.BACKGROUND];
                            BaseColor color = (BaseColor) back[0];
                            this.SetAttribute(PdfName.BACKGROUNDCOLOR,
                                              new PdfArray(new float[] {color.R/255f, color.G/255f, color.B/255f}));
                        }

                        // Setting inheritable attributes
                        IPdfStructureElement parent = (IPdfStructureElement) this.GetParent(true);
                        PdfObject obj = parent.GetAttribute(PdfName.COLOR);
                        if ((chunk.Font != null) && (chunk.Font.Color != null))
                        {
                            BaseColor c = chunk.Font.Color;
                            SetColorAttribute(c, obj, PdfName.COLOR);
                        }
                        PdfObject decorThickness = parent.GetAttribute(PdfName.TEXTDECORATIONTHICKNESS);
                        PdfObject decorColor = parent.GetAttribute(PdfName.TEXTDECORATIONCOLOR);
                        if (attr.ContainsKey(Chunk.UNDERLINE))
                        {
                            Object[][] unders = (Object[][]) attr[Chunk.UNDERLINE];
                            Object[] arr = unders[unders.Length - 1];
                            BaseColor color = (BaseColor) arr[0];
                            float[] floats = (float[]) arr[1];
                            float thickness = floats[0];
                            // Setting thickness
                            if (decorThickness is PdfNumber)
                            {
                                float t = ((PdfNumber) decorThickness).FloatValue;
                                if (thickness.CompareTo(t) != 0)
                                    this.SetAttribute(PdfName.TEXTDECORATIONTHICKNESS, new PdfNumber(thickness));
                            }
                            else
                                this.SetAttribute(PdfName.TEXTDECORATIONTHICKNESS, new PdfNumber(thickness));

                            // Setting decoration color
                            if (color != null)
                                SetColorAttribute(color, decorColor, PdfName.TEXTDECORATIONCOLOR);
                        }

                        if (attr.ContainsKey(Chunk.LINEHEIGHT))
                        {
                            float height = (float) attr[Chunk.LINEHEIGHT];
                            PdfObject parentLH = parent.GetAttribute(PdfName.LINEHEIGHT);
                            if (parentLH is PdfNumber)
                            {
                                float pLH = ((PdfNumber) parentLH).FloatValue;
                                if (pLH.CompareTo(height) != 0)
                                    this.SetAttribute(PdfName.LINEHEIGHT, new PdfNumber(height));
                            }
                            else
                                this.SetAttribute(PdfName.LINEHEIGHT, new PdfNumber(height));
                        }
                    }
                }
            }
        }
开发者ID:,项目名称:,代码行数:71,代码来源:


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