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


C# Chunk.SetTextRise方法代码示例

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


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

示例1: CreateChunk

 public Chunk CreateChunk(String text, ChainedProperties props) {
     Font font = GetFont(props);
     float size = font.Size;
     size /= 2;
     Chunk ck = new Chunk(text, font);
     if (props.HasProperty("sub"))
         ck.SetTextRise(-size);
     else if (props.HasProperty("sup"))
         ck.SetTextRise(size);
     ck.SetHyphenation(GetHyphenation(props));
     return ck;
 }
开发者ID:,项目名称:,代码行数:12,代码来源:

示例2: Write

// ===========================================================================
    public void Write(Stream stream) {
      // step 1
      using (Document document = new Document()) {
        // step 2
        PdfWriter.GetInstance(document, stream).InitialLeading = 16;
        // step 3
        document.Open();
        // add the ID in another font
        Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD, BaseColor.WHITE);
        // step 4
        using (var c =  AdoDB.Provider.CreateConnection()) {
          c.ConnectionString = AdoDB.CS;
          using (DbCommand cmd = c.CreateCommand()) {
            cmd.CommandText = 
              "SELECT country,id FROM film_country ORDER BY country";
            c.Open();
            using (var r = cmd.ExecuteReader()) {
              while (r.Read()) {
                var country = r.GetString(0);
                var ID = r.GetString(1);
                document.Add(new Chunk(country));
                document.Add(new Chunk(" "));
                Chunk id = new Chunk(ID, font);
                // with a background color
                id.SetBackground(BaseColor.BLACK, 1f, 0.5f, 1f, 1.5f);
                // and a text rise
                id.SetTextRise(6);
                document.Add(id);
                document.Add(Chunk.NEWLINE);
              }
            }
          }
        }
      }
    }
开发者ID:,项目名称:,代码行数:36,代码来源:

示例3: CreateChunk

 /**
  * Creates an iText Chunk
  * @param content the content of the Chunk
  * @param chain the hierarchy chain
  * @return a Chunk
  */
 public Chunk CreateChunk(String content, ChainedProperties chain) {
     Font font = GetFont(chain);
     Chunk ck = new Chunk(content, font);
     if (chain.HasProperty(HtmlTags.SUB))
         ck.SetTextRise(-font.Size / 2);
     else if (chain.HasProperty(HtmlTags.SUP))
         ck.SetTextRise(font.Size / 2);
     ck.SetHyphenation(GetHyphenation(chain));
     return ck;
 }
开发者ID:Gianluigi,项目名称:dssnet,代码行数:16,代码来源:ElementFactory.cs

示例4: GetChunk

        public static Chunk GetChunk(Properties attributes)
        {
            Chunk chunk = new Chunk();

            chunk.Font = FontFactory.GetFont(attributes);
            String value;

            value = attributes[ElementTags.ITEXT];
            if (value != null) {
                chunk.Append(value);
            }
            value = attributes[ElementTags.LOCALGOTO];
            if (value != null) {
                chunk.SetLocalGoto(value);
            }
            value = attributes[ElementTags.REMOTEGOTO];
            if (value != null) {
                String page = attributes[ElementTags.PAGE];
                if (page != null) {
                    chunk.SetRemoteGoto(value, int.Parse(page));
                }
                else {
                    String destination = attributes[ElementTags.DESTINATION];
                    if (destination != null) {
                        chunk.SetRemoteGoto(value, destination);
                    }
                }
            }
            value = attributes[ElementTags.LOCALDESTINATION];
            if (value != null) {
                chunk.SetLocalDestination(value);
            }
            value = attributes[ElementTags.SUBSUPSCRIPT];
            if (value != null) {
                chunk.SetTextRise(float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            value = attributes[Markup.CSS_KEY_VERTICALALIGN];
            if (value != null && value.EndsWith("%")) {
                float p = float.Parse(value.Substring(0, value.Length - 1), System.Globalization.NumberFormatInfo.InvariantInfo) / 100f;
                chunk.SetTextRise(p * chunk.Font.Size);
            }
            value = attributes[ElementTags.GENERICTAG];
            if (value != null) {
                chunk.SetGenericTag(value);
            }
            value = attributes[ElementTags.BACKGROUNDCOLOR];
            if (value != null) {
                chunk.SetBackground(Markup.DecodeColor(value));
            }
            return chunk;
        }
开发者ID:bmictech,项目名称:iTextSharp,代码行数:51,代码来源:ElementFactory.cs

示例5: createPdfWithSupescript

        private byte[] createPdfWithSupescript(String regularText, String superscriptText)
        {
            MemoryStream byteStream = new MemoryStream();

            Document document = new Document();
            PdfWriter.GetInstance(document, byteStream);
            document.Open();
            document.Add(new Chunk(regularText));
            Chunk c2 = new Chunk(superscriptText);
            c2.SetTextRise(7.0f);
            document.Add(c2);

            document.Close();

            byte[] pdfBytes = byteStream.ToArray();

            return pdfBytes;
        }
开发者ID:,项目名称:,代码行数:18,代码来源:

示例6: MainExample


//.........这里部分代码省略.........
            par.Add (new Chunk (text, font));
            text="Courier New 15pt. ";
            font = FontFactory.GetFont (GetFontByName ("Courier New"), 15);
            par.Add (new Chunk (text, font));
            text="Courier New 20pt. ";
            font = FontFactory.GetFont (FontFactory.COURIER, 20); //GetFontByName ("Courier New") == FontFactory.COURIER
            par.Add (new Chunk (text, font));
            doc.Add (par);

            //Normal, Italic, Oblique
            //Not Finished
            par = new Paragraph();
            par.SpacingBefore = spacingAfter;
            par.SpacingAfter = spacingAfter;
            text = "Normal. ";
            font = FontFactory.GetFont (GetFontByName ("Arial"), textFontSize, Font.NORMAL);
            par.Add (new Chunk (text, font));
            text = "Italic. ";
            font = FontFactory.GetFont (GetFontByName ("Arial"), textFontSize, Font.ITALIC);
            par.Add (new Chunk (text, font));
            text = "Oblique. (Not Working)";
            font = FontFactory.GetFont (GetFontByName ("Arial"), textFontSize);
            par.Add (new Chunk (text, font));
            doc.Add (par);

            //Normal. Subscript. Superscript.
            //H 2 O
            doc.Add(new Paragraph("Normal. Subscript. Superscript."));
            par = new Paragraph ();
            par.SpacingBefore = spacingAfter;
            chunk = new Chunk ("H", FontFactory.GetFont (GetFontByName ("Arial")));
            par.Add (chunk);
            chunk = new Chunk ("2", FontFactory.GetFont (GetFontByName ("Arial")));
            chunk.SetTextRise (-5f);
            par.Add (chunk);
            chunk = new Chunk ("O", FontFactory.GetFont (GetFontByName ("Arial")));
            par.Add (chunk);
            doc.Add (par);
            //C 2 H 5 OH
            par = new Paragraph ();
            par.SpacingBefore = spacingAfter;
            chunk = new Chunk ("C", FontFactory.GetFont (GetFontByName ("Arial")));
            par.Add (chunk);
            chunk = new Chunk ("2", FontFactory.GetFont (GetFontByName ("Arial")));
            chunk.SetTextRise (-5f);
            par.Add (chunk);
            chunk = new Chunk ("H", FontFactory.GetFont (GetFontByName ("Arial")));
            par.Add (chunk);
            chunk = new Chunk ("5", FontFactory.GetFont (GetFontByName ("Arial")));
            chunk.SetTextRise (-5f);
            par.Add (chunk);
            chunk = new Chunk ("OH", FontFactory.GetFont (GetFontByName ("Arial")));
            par.Add (chunk);
            doc.Add (par);
            //a^2+b^2=c^2
            par = new Paragraph ();
            par.SpacingBefore = spacingAfter;
            chunk = new Chunk ("a", FontFactory.GetFont (GetFontByName ("Arial")));
            par.Add (chunk);
            chunk = new Chunk ("2", FontFactory.GetFont (GetFontByName ("Arial")));
            chunk.SetTextRise (5f);
            par.Add (chunk);
            chunk = new Chunk (" + b", FontFactory.GetFont (GetFontByName ("Arial")));
            par.Add (chunk);
            chunk = new Chunk ("2", FontFactory.GetFont (GetFontByName ("Arial")));
            chunk.SetTextRise (5f);
开发者ID:sunriselink,项目名称:TestPDF,代码行数:67,代码来源:Program.cs

示例7: ReportBuilder


//.........这里部分代码省略.........
                            PdfReports.AddText2Table(table, "Explanation", _labelFont, _bodyLayout.Length);

                            PdfReports.AddText2Table(table, " ", _subFont, _bodyLayout.Length);
                            para = new Paragraph("Created by Congress, the domestic production activities deduction has been in effect since 2005.  It is designed "
                                + "to encourage businesses like WSC to engage in production and/or manufacturing activities in the United States "
                                + "and to employ workers in those activities.",
                                _normalFont);
                            PdfReports.AddText2Table(table, para, _bodyLayout.Length);

                            PdfReports.AddText2Table(table, " ", _subFont, _bodyLayout.Length);
                            para = new Paragraph("Section 199(d)(3) of the Internal Revenue Code contains special rules governing how cooperatives and their "
                                + "patrons must compute the deduction.  The Code permits a cooperative to elect to pass through to patrons all or a "
                                + "portion of its domestic production activities deduction.  Cooperatives typically pass through to patrons whatever "
                                + "part of the deduction they can not themselves use.",
                                _normalFont);
                            PdfReports.AddText2Table(table, para, _bodyLayout.Length);

                            string pctToApply = "All";
                            if (state.PercentageToApply != 100) {
                                pctToApply = state.PercentageToApply.ToString("N3");
                                if (pctToApply.EndsWith("000")) {
                                    pctToApply = state.PercentageToApply.ToString("N0");
                                }
                                pctToApply += "%";
                            }
                            PdfReports.AddText2Table(table, " ", _subFont, _bodyLayout.Length);

                            para = new Paragraph("WSC is passing through to its patrons " + pctToApply + " of the domestic production activities deduction it earned "
                                + "for the fiscal year ending " + state.FiscalYearEndDate.ToShortDateString() + ".  The passthrough is being allocated to patrons based on sugar "
                                + "beet tonnage for Crop Year " + state.CropYear.ToString()
                                + " (fiscal year " + state.FiscalYear.ToString() + ").  This notice identifies your share of the "
                                + "passthrough. ",
                                _normalFont);
                            PdfReports.AddText2Table(table, para, _bodyLayout.Length);

                            PdfReports.AddText2Table(table, " ", _subFont, _bodyLayout.Length);
                            para = new Paragraph("A domestic production activities deduction passed through to a patron can generally be used to reduce the "
                                + "patron’s taxable income.  In order to claim this passed-through deduction, a patron must include a Form 8903 "
                                + "(Domestic Production Activities Deduction) with the patron’s income tax return and report the passthrough "
                                + "deduction on the appropriate line of that form.",
                                _normalFont);
                            PdfReports.AddText2Table(table, para, _bodyLayout.Length);

                            PdfReports.AddText2Table(table, " ", _subFont, _bodyLayout.Length);
                            PdfReports.AddText2Table(table, " ", _normalFont);
                            PdfReports.AddText2Table(table, "We strongly advise you consult with your tax advisor to determine how to take\n"
                                + "advantage of this potential tax benefit.", _labelFont, "center");
                            PdfReports.AddText2Table(table, " ", _normalFont);

                            PdfReports.AddText2Table(table, " ", _subFont, _bodyLayout.Length);
                            PdfReports.AddText2Table(table, " ", _subFont, _bodyLayout.Length);

                            para = new Paragraph("______________________________\n\n", _subFont);
                            Chunk ck = new Chunk("1", _subFont);
                            ck.SetTextRise(5);
                            para.Add(ck);
                            Chunk chunk = new Chunk(" This notice is issued pursuant to Section 199(d)(3) of the Internal Revenue Code.", _subFont);
                            para.Add(chunk);
                            PdfReports.AddText2Table(table, para, _bodyLayout.Length);

                            PdfReports.AddTableNoSplit(document, pgEvent, table);
                        }

                        // ======================================================
                        // Close document
                        // ======================================================
                        if (document != null) {
                            pgEvent.IsDocumentClosing = true;
                            document.Close();
                            document = null;
                        }
                        if (writer == null) {
                            // Warn that we have no data.
                            WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("No records matched your report criteria.");
                            throw (warn);
                        }
                    }
                } else {
                    // No recs qualified for query.
                    WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("No records matched your query.");
                    throw(warn);
                }
            }
            catch (System.Exception ex) {

                string errMsg = "cropYear: " + cropYear.ToString();
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + "." + METHOD_NAME + ": " + errMsg, ex);
                throw (wscEx);
            }
            finally {

                if (document != null) {
                    pgEvent.IsDocumentClosing = true;
                    document.Close();
                }
                if (writer != null) {
                    writer.Close();
                }
            }
        }
开发者ID:jwebb-vtg,项目名称:WSCIEMP,代码行数:101,代码来源:rptNoticeOfPassthrough.cs

示例8: 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

示例9: Apply

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

        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)) {
                    c.SetCharacterSpacing(utils.ParsePxInCmMmPcToPt(value));
                } 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))
            {
                // Restriction? In html a underline and a line-through is possible on one piece of text. A Chunk can set an underline only once.
                if (Util.EqualsIgnoreCase(CSS.Value.UNDERLINE, value))
                {
                    c.SetUnderline(0.75f, -size/8f);
                }
                if (Util.EqualsIgnoreCase(CSS.Value.LINE_THROUGH, value))
                {
                    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;
            return c;
        }
开发者ID:,项目名称:,代码行数:74,代码来源:

示例10: GetDayCell

 //// ---------------------------------------------------------------------------   
 //    /**
 //     * Creates a PdfPCell for a specific day
 //     * @param dt a DateTime
 //     * @return a PdfPCell
 //     */
 public PdfPCell GetDayCell(DateTime dt)
 {
     PdfPCell cell = new PdfPCell();
     cell.Padding = 3;
     // set the background color, based on the type of day
     cell.BackgroundColor = IsSunday(dt)
       ? BaseColor.GRAY
       : IsSpecialDay(dt)
         ? BaseColor.LIGHT_GRAY
         : BaseColor.WHITE
     ;
     // set the content in the language of the locale
     Chunk chunk = new Chunk(dt.ToString("ddd"), small);
     chunk.SetTextRise(8);
     // a paragraph with the day
     Paragraph p = new Paragraph(chunk);
     // a separator
     p.Add(new Chunk(new VerticalPositionMark()));
     // and the number of the day
     p.Add(new Chunk(dt.ToString("%d"), normal));
     cell.AddElement(p);
     return cell;
 }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:29,代码来源:PdfCalendar.cs

示例11: CreateChunk

 public Chunk CreateChunk(String text, ChainedProperties props)
 {
     Chunk ck = new Chunk(text, GetFont(props));
     if (props.HasProperty("sub"))
         ck.SetTextRise(-6);
     else if (props.HasProperty("sup"))
         ck.SetTextRise(6);
     return ck;
 }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:9,代码来源:FactoryProperties.cs

示例12: Genera

        public static void Genera(string sourcePath,string content)
        {
            sourcePath = HttpContext.Current.Server.MapPath(sourcePath);
            //定义一个Document,并设置页面大小为A4,竖向
            iTextSharp.text.Document doc = new Document(PageSize.A4);
            try
            {
                //写实例
                PdfWriter.GetInstance(doc, new FileStream(sourcePath, FileMode.Create));
                //打开document
                doc.Open();

                //载入字体
                BaseFont baseFont = BaseFont.CreateFont(
                    "C:\\WINDOWS\\FONTS\\SIMHEI.TTF", //黑体
                    BaseFont.IDENTITY_H, //横向字体
                    BaseFont.NOT_EMBEDDED);
                iTextSharp.text.Font font = new iTextSharp.text.Font(baseFont, 9);

                //写入一个段落, Paragraph
                doc.Add(new Paragraph("第一段:" + content, font));
                doc.Add(new Paragraph("这是第二段 !", font));

                #region 图片
                //以下代码用来添加图片,此时图片是做为背景加入到pdf文件当中的:

                Stream inputImageStream = new FileStream(HttpContext.Current.Server.MapPath("~/images/logo.jpg"), FileMode.Open, FileAccess.Read, FileShare.Read);
                iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(inputImageStream);
                image.SetAbsolutePosition(0, 0);
                image.Alignment = iTextSharp.text.Image.UNDERLYING;    //这里可以设定图片是做为背景还是做为元素添加到文件中
                doc.Add(image);

                #endregion
                #region 其他元素
                doc.Add(new Paragraph("Hello World"));
                //另起一行。有几种办法建立一个段落,如:
                Paragraph p1 = new Paragraph(new Chunk("This is my first paragraph.\n", FontFactory.GetFont(FontFactory.HELVETICA, 12)));
                Paragraph p2 = new Paragraph(new Phrase("This is my second paragraph.", FontFactory.GetFont(FontFactory.HELVETICA, 12)));
                Paragraph p3 = new Paragraph("This is my third paragraph.", FontFactory.GetFont(FontFactory.HELVETICA, 12));
                //所有有些对象将被添加到段落中:
                p1.Add("you can add string here\n\t");
                p1.Add(new Chunk("you can add chunks \n")); p1.Add(new Phrase("or you can add phrases.\n"));
                doc.Add(p1); doc.Add(p2); doc.Add(p3);

                //创建了一个内容为“hello World”、红色、斜体、COURIER字体、尺寸20的一个块:
                Chunk chunk = new Chunk("创建了一个内容为“hello World”、红色、斜体、COURIER字体、尺寸20的一个块", FontFactory.GetFont(FontFactory.COURIER, 20, iTextSharp.text.Font.COURIER, new iTextSharp.text.Color(255, 0, 0)));
                doc.Add(chunk);
                //如果你希望一些块有下划线或删除线,你可以通过改变字体风格简单做到:
                Chunk chunk1 = new Chunk("This text is underlined", FontFactory.GetFont(FontFactory.HELVETICA, 12, iTextSharp.text.Font.UNDEFINED));
                Chunk chunk2 = new Chunk("This font is of type ITALIC | STRIKETHRU", FontFactory.GetFont(FontFactory.HELVETICA, 12, iTextSharp.text.Font.ITALIC | iTextSharp.text.Font.STRIKETHRU));
                //改变块的背景
                chunk2.SetBackground(new iTextSharp.text.Color(0xFF, 0xFF, 0x00));
                //上标/下标
                chunk1.SetTextRise(5);
                doc.Add(chunk1);
                doc.Add(chunk2);

                //外部链接示例:
                Anchor anchor = new Anchor("website", FontFactory.GetFont(FontFactory.HELVETICA, 12, iTextSharp.text.Font.UNDEFINED, new iTextSharp.text.Color(0, 0, 255)));
                anchor.Reference = "http://itextsharp.sourceforge.net";
                anchor.Name = "website";
                //内部链接示例:
                Anchor anchor1 = new Anchor("This is an internal link\n\n");
                anchor1.Name = "link1";
                Anchor anchor2 = new Anchor("Click here to jump to the internal link\n\f");
                anchor2.Reference = "#link1";
                doc.Add(anchor); doc.Add(anchor1); doc.Add(anchor2);

                //排序列表示例:
                List list = new List(true, 20);
                list.Add(new ListItem("First line"));
                list.Add(new ListItem("The second line is longer to see what happens once the end of the line is reached. Will it start on a new line?"));
                list.Add(new ListItem("Third line"));
                doc.Add(list);

                //文本注释:
                Annotation a = new Annotation("authors", "Maybe its because I wanted to be an author myself that I wrote iText.");
                doc.Add(a);

                //包含页码没有任何边框的页脚。
                iTextSharp.text.HeaderFooter footer = new iTextSharp.text.HeaderFooter(new Phrase("This is page: "), true);
                footer.Border = iTextSharp.text.Rectangle.NO_BORDER;
                doc.Footer = footer;

                //Chapter对象和Section对象自动构建一个树:
                iTextSharp.text.Font f1 = new iTextSharp.text.Font();
                f1.SetStyle(iTextSharp.text.Font.BOLD);
                Paragraph cTitle = new Paragraph("This is chapter 1", f1);
                Chapter chapter = new Chapter(cTitle, 1);
                Paragraph sTitle = new Paragraph("This is section 1 in chapter 1", f1);
                Section section = chapter.AddSection(sTitle, 1);
                doc.Add(chapter);

                //构建了一个简单的表:
                Table aTable = new Table(4, 4);
                aTable.AutoFillEmptyCells = true;
                aTable.AddCell("2.2", new System.Drawing.Point(2, 2));
                aTable.AddCell("3.3", new System.Drawing.Point(3, 3));
                aTable.AddCell("2.1", new System.Drawing.Point(2, 1));
                aTable.AddCell("1.3", new System.Drawing.Point(1, 3));
//.........这里部分代码省略.........
开发者ID:gofixiao,项目名称:dlerp,代码行数:101,代码来源:OfficeHelper.cs


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