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


C# Chunk.SetSplitCharacter方法代码示例

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


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

示例1: Go

        public void Go()
        {
            // GetClassOutputPath() implementation left out for brevity
            var outputFile = Helpers.IO.GetClassOutputPath(this);

            using (FileStream stream = new FileStream(
                outputFile, 
                FileMode.Create, 
                FileAccess.Write))
            {
                Random random = new Random();

                StreamUtil.AddToResourceSearch(("iTextAsian.dll"));
                string chunkText = " 你好世界 你好你好,";
                var font = new Font(BaseFont.CreateFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 12);

                using (Document document = new Document())
                {
                    PdfWriter.GetInstance(document, stream);
                    document.Open();
                    Phrase phrase = new Phrase();
                    Chunk chunk = new Chunk("", font);
                    for (var i = 0; i < 1000; ++i)
                    {
                        var asterisk = new String('*', random.Next(1, 20));
                        chunk.Append(
                            string.Format("[{0}] {1} ", asterisk, chunkText) 
                        );
                    }
                    chunk.SetSplitCharacter(new CustomSplitCharacter());
                    phrase.Add(chunk);
                    document.Add(phrase);
                }
            }
        }
开发者ID:kuujinbo,项目名称:StackOverflow.iTextSharp,代码行数:35,代码来源:ChineseSetSplitCharacter.cs

示例2: Write

        // ===========================================================================
        public void Write(Stream stream)
        {
            // step 1
            using (Document document = new Document(
              new Rectangle(240, 240), 10, 10, 10, 10
            ))
            {
                // step 2
                PdfWriter writer = PdfWriter.GetInstance(document, stream);
                // step 3
                document.Open();
                // step 4
                // create a long Stringbuffer with movie titles
                StringBuilder sb = new StringBuilder();
                IEnumerable<Movie> movies = PojoFactory.GetMovies(1);
                foreach (Movie movie in movies)
                {
                    // replace spaces with non-breaking spaces
                    sb.Append(movie.MovieTitle.Replace(' ', '\u00a0'));
                    // use pipe as separator
                    sb.Append('|');
                }
                // Create a first chunk
                Chunk chunk1 = new Chunk(sb.ToString());
                // wrap the chunk in a paragraph and add it to the document
                Paragraph paragraph = new Paragraph("A:\u00a0");
                paragraph.Add(chunk1);
                paragraph.Alignment = Element.ALIGN_JUSTIFIED;
                document.Add(paragraph);
                document.Add(Chunk.NEWLINE);
                // define the pipe character as split character
                chunk1.SetSplitCharacter(new PipeSplitCharacter());
                // wrap the chunk in a second paragraph and add it
                paragraph = new Paragraph("B:\u00a0");
                paragraph.Add(chunk1);
                paragraph.Alignment = Element.ALIGN_JUSTIFIED;
                document.Add(paragraph);
                document.Add(Chunk.NEWLINE);

                // create a new StringBuffer with movie titles
                sb = new StringBuilder();
                foreach (Movie movie in movies)
                {
                    sb.Append(movie.MovieTitle);
                    sb.Append('|');
                }
                // Create a second chunk 
                Chunk chunk2 = new Chunk(sb.ToString());
                // wrap the chunk in a paragraph and add it to the document
                paragraph = new Paragraph("C:\u00a0");
                paragraph.Add(chunk2);
                paragraph.Alignment = Element.ALIGN_JUSTIFIED;
                document.Add(paragraph);
                document.NewPage();
                // define hyphenation for the chunk
                chunk2.SetHyphenation(new HyphenationAuto("en", "US", 2, 2));
                // wrap the second chunk in a second paragraph and add it
                paragraph = new Paragraph("D:\u00a0");
                paragraph.Add(chunk2);
                paragraph.Alignment = Element.ALIGN_JUSTIFIED;
                document.Add(paragraph);

                // go to a new page
                document.NewPage();
                // define a new space/char ratio
                writer.SpaceCharRatio = PdfWriter.NO_SPACE_CHAR_RATIO;
                // wrap the second chunk in a third paragraph and add it
                paragraph = new Paragraph("E:\u00a0");
                paragraph.Add(chunk2);
                paragraph.Alignment = Element.ALIGN_JUSTIFIED;
                document.Add(paragraph);
            }
        }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:74,代码来源:MovieChain.cs

示例3: Go

        public void Go()
        {
            // GetClassOutputPath() implementation left out for brevity
            var outputFile = Helpers.IO.GetClassOutputPath(this);

            using (FileStream stream = new FileStream(
                outputFile, 
                FileMode.Create, 
                FileAccess.Write))
            {
                string chunkText = "FirstName LastName (2016-01-13 11:13)";
                Random random = new Random();
                var font = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD); 
                using (Document document = new Document())
                {
                    PdfWriter.GetInstance(document, stream);
                    document.Open();
                    Phrase phrase = new Phrase();
                    for (var i = 0; i < 1000; ++i)
                    {
                        var asterisk = new String('*', random.Next(1, 20));
                        Chunk chunk = new Chunk(
                            string.Format("[{0}] {1}", asterisk, chunkText), 
                            font
                        );
                        chunk.SetSplitCharacter(new CustomSplitCharacter());
                        phrase.Add(chunk);
                    }
 
                    document.Add(phrase);
                }
            }
        }
开发者ID:kuujinbo,项目名称:StackOverflow.iTextSharp,代码行数:33,代码来源:SetSplitCharacter.cs


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