當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。