當前位置: 首頁>>代碼示例>>C#>>正文


C# text.Phrase類代碼示例

本文整理匯總了C#中iTextSharp.text.Phrase的典型用法代碼示例。如果您正苦於以下問題:C# Phrase類的具體用法?C# Phrase怎麽用?C# Phrase使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Phrase類屬於iTextSharp.text命名空間,在下文中一共展示了Phrase類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateMovieInformation

 // ---------------------------------------------------------------------------    
 /**
  * Creates a Phrase containing information about a movie.
  * @param    movie    the movie for which you want to create a Paragraph
  */
 public Phrase CreateMovieInformation(Movie movie)
 {
     Phrase p = new Phrase();
     p.Font = FilmFonts.NORMAL;
     p.Add(new Phrase("Title: ", FilmFonts.BOLDITALIC));
     p.Add(PojoToElementFactory.GetMovieTitlePhrase(movie));
     p.Add(" ");
     if (!string.IsNullOrEmpty(movie.OriginalTitle))
     {
         p.Add(new Phrase("Original title: ", FilmFonts.BOLDITALIC));
         p.Add(PojoToElementFactory.GetOriginalTitlePhrase(movie));
         p.Add(" ");
     }
     p.Add(new Phrase("Country: ", FilmFonts.BOLDITALIC));
     foreach (Country country in movie.Countries)
     {
         p.Add(PojoToElementFactory.GetCountryPhrase(country));
         p.Add(" ");
     }
     p.Add(new Phrase("Director: ", FilmFonts.BOLDITALIC));
     foreach (Director director in movie.Directors)
     {
         p.Add(PojoToElementFactory.GetDirectorPhrase(director));
         p.Add(" ");
     }
     p.Add(new Chunk("Year: ", FilmFonts.BOLDITALIC));
     p.Add(new Chunk(movie.Year.ToString(), FilmFonts.NORMAL));
     p.Add(new Chunk(" Duration: ", FilmFonts.BOLDITALIC));
     p.Add(new Chunk(movie.Duration.ToString(), FilmFonts.NORMAL));
     p.Add(new Chunk(" minutes", FilmFonts.NORMAL));
     p.Add(new LineSeparator(0.3f, 100, null, Element.ALIGN_CENTER, -2));
     return p;
 }
開發者ID:kuujinbo,項目名稱:iTextInAction2Ed,代碼行數:38,代碼來源:MovieColumns1.cs

示例2: OnEndPage

        //重寫 關閉一個頁麵時
        public override void OnEndPage(PdfWriter writer, Document document)
        {
            try
            {
                Font font = new Font(basefont, defaultFontSize);
                Phrase head = new Phrase(header, font);
                PdfContentByte cb = writer.DirectContent;
               
                //頁眉顯示的位置
                ColumnText.ShowTextAligned(cb, Element.ALIGN_RIGHT, head,
                        document.Right - 10 + document.LeftMargin, document.Top + 10, 0);
                if (PAGE_NUMBER)
                {
                    Phrase footer = new Phrase("第 " + writer.PageNumber + " / " + "   "+" 頁", font);
                    cb = writer.DirectContent;
                    //tpl = cb.CreateTemplate(100, 100);
                    //模版 顯示總共頁數
                    cb.AddTemplate(tpl, document.Left / 2 + document.Right / 2 , document.Bottom - 10);//調節模版顯示的位置
                    //頁腳顯示的位置
                    ColumnText.ShowTextAligned(cb, Element.ALIGN_RIGHT, footer,
                            document.Left / 2+document.Right/ 2+23, document.Bottom - 10, 0);
                    

                }
            }
            catch (Exception ex)
            {
                throw new Exception("HeaderAndFooterEvent-->OnEndPage-->" + ex.Message);
            }
        }
開發者ID:lxh2014,項目名稱:gigade-net,代碼行數:31,代碼來源:HeaderAndFooterEvent.cs

示例3: GenerateReportTable

        private static PdfPTable GenerateReportTable(DayReport report)
        {
            PdfPTable table = new PdfPTable(5);
            
            string[] headerTitles = {"Product", "Quantity", "Unit Price", "Location", "Sum"};
            foreach (var title in headerTitles)
            {
                Phrase phrase = new Phrase(title);
                phrase.Font = FontFactory.GetFont("Arial", 14, Font.BOLD);
                PdfPCell cell = new PdfPCell(phrase);
                cell.BackgroundColor = new BaseColor(175, 166, 166);
                table.AddCell(cell);
                cell.Padding = 0;
            }

            foreach (var sale in report.Sales)
            {
                table.AddCell(sale.ProductName);
                table.AddCell(sale.MeasureFormatted);
                table.AddCell(sale.UnitPrice.ToString());
                table.AddCell(sale.Supermarket);
                table.AddCell(sale.Sum.ToString());
            }

            PdfPCell footerCell = new PdfPCell(new Phrase("Total sum for " + report.FormattedDate + ": "));
            footerCell.Colspan = 4;
            footerCell.HorizontalAlignment = 2;
            table.AddCell(footerCell);
            table.AddCell(new Phrase(report.TotalSum.ToString()));
            return table;
        }
開發者ID:NikolayKostadinov,項目名稱:TelerikAkademy,代碼行數:31,代碼來源:PdfReportGenerator.cs

示例4: AddText

        /// <summary>
        /// <para>座標を指定してテキストを追加します。</para>
        /// <para>PDF では用紙左上が座標基準 (0, 0) である點に注意してください。</para>
        /// </summary>
        /// <param name="text">追加するテキスト</param>
        /// <param name="fontSize">フォントサイズ</param>
        /// <param name="x">X 座標</param>
        /// <param name="y">Y座標</param>
        public void AddText(string text, int fontSize, int x, int y)
        {
            // 左下の座標
            float llx = x;
            float lly = 0f;

            // 右上の座標
            float urx = this.Page.Width;
            float ury = y;

            var pcb = this.Writer.DirectContent;
            var ct = new ColumnText(pcb);
            var font = new Font(this.BaseFont, fontSize, Font.NORMAL);

            var phrase = new Phrase(text, font);

            ct.SetSimpleColumn(
                phrase,
                llx,
                lly,
                urx,
                ury,
                0,
                Element.ALIGN_LEFT | Element.ALIGN_TOP
                );

            // 以下を実行して反映する (消さないこと)
            ct.Go();
        }
開發者ID:pine,項目名稱:KutDormitoryReport,代碼行數:37,代碼來源:PdfReport.cs

示例5: GetFormattedCell

        private static PDF.PdfPCell GetFormattedCell(TableCell cell)
        {
            PDF.PdfPCell formattedCell = new PDF.PdfPCell();

            Element[] cellElements = cell.SubElements;

            foreach (Element temp in cellElements)
            {
                switch (temp.GetElementType())
                {
                    //TODO: Add other enum values
                    case ElementType.Text:
                        IT.Phrase phrase = new IT.Phrase(TextFormatter.GetFormattedText((Text)temp));
                        formattedCell.AddElement(phrase);
                        break;

                    case ElementType.Paragraph:
                        formattedCell.AddElement(ParagraphFormatter.GetFormattedParagraph((Paragraph)temp));
                        break;

                    case ElementType.Table:
                        formattedCell.AddElement(TableFormatter.GetFormattedTable((Table)temp));
                        break;

                    case ElementType.Image:
                        formattedCell.AddElement(ImageFormatter.GetFormattedImage((Image)temp));
                        break;
                }

            }

            return formattedCell;
        }
開發者ID:amilasurendra,項目名稱:pdf-generator,代碼行數:33,代碼來源:TableFormatter.cs

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

示例7: Add

        public void Add(Athlete athete)
        {
            var data =
            new IT.Phrase(athete.Id.ToString() ,
                          IT.FontFactory.GetFont(IT.FontFactory.HELVETICA, SIZE_ROW, IT.Font.NORMAL));

              var cell = new IT.pdf.PdfPCell(data);
              cell.HorizontalAlignment = IT.Element.ALIGN_LEFT;
              cell.PaddingBottom = PAD_BOTTOM;
              table.AddCell(cell);

             data = new IT.Phrase(athete.Surname + " "  + athete.Name,
                              IT.FontFactory.GetFont(IT.FontFactory.HELVETICA, SIZE_ROW, IT.Font.NORMAL));
             cell = new IT.pdf.PdfPCell(data);
             cell.HorizontalAlignment = IT.Element.ALIGN_LEFT;
             cell.PaddingBottom = PAD_BOTTOM;
             table.AddCell(cell);

             data = new IT.Phrase(" ",
                              IT.FontFactory.GetFont(IT.FontFactory.HELVETICA, SIZE_TITLE, IT.Font.NORMAL));
             cell = new IT.pdf.PdfPCell(data);
             cell.HorizontalAlignment = IT.Element.ALIGN_LEFT;
             cell.PaddingBottom = PAD_BOTTOM;
             table.AddCell(cell);
        }
開發者ID:o3o,項目名稱:LdgLite,代碼行數:25,代碼來源:ListBuilder.cs

示例8: Write

 // ---------------------------------------------------------------------------          
 public void Write(Stream stream)
 {
     // step 1
     using (Document document = new Document())
     {
         // step 2
         PdfWriter writer = PdfWriter.GetInstance(document, stream);
         // step 3
         document.Open();
         // step 4
         Phrase phrase;
         Chunk chunk;
         foreach (Movie movie in PojoFactory.GetMovies())
         {
             phrase = new Phrase(movie.MovieTitle);
             chunk = new Chunk("\u00a0");
             chunk.SetAnnotation(PdfAnnotation.CreateText(
               writer, null, movie.MovieTitle,
               string.Format(INFO, movie.Year, movie.Duration),
               false, "Comment"
             ));
             phrase.Add(chunk);
             document.Add(phrase);
             document.Add(PojoToElementFactory.GetDirectorList(movie));
             document.Add(PojoToElementFactory.GetCountryList(movie));
         }
     }
 }
開發者ID:kuujinbo,項目名稱:iTextInAction2Ed,代碼行數:29,代碼來源:MovieAnnotations2.cs

示例9: TextLeadingTest

        public void TextLeadingTest() {
            String file = "phrases.pdf";

            Document document = new Document();
            PdfWriter writer = PdfWriter.GetInstance(document, File.Create(OUTPUT_FOLDER + file));
            document.Open();

            Phrase p1 = new Phrase("first, leading of 150");
            p1.Leading = 150;
            document.Add(p1);
            document.Add(Chunk.NEWLINE);

            Phrase p2 = new Phrase("second, leading of 500");
            p2.Leading = 500;
            document.Add(p2);
            document.Add(Chunk.NEWLINE);

            Phrase p3 = new Phrase();
            p3.Add(new Chunk("third, leading of 20"));
            p3.Leading = 20;
            document.Add(p3);

            document.Close();

            // compare
            CompareTool compareTool = new CompareTool();
            String errorMessage = compareTool.CompareByContent(OUTPUT_FOLDER + file, TEST_RESOURCES_PATH + file, OUTPUT_FOLDER, "diff");
            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }
        }
開發者ID:newlysoft,項目名稱:itextsharp,代碼行數:31,代碼來源:DocumentLayoutTest.cs

示例10: OnChapter

 /**
  * Initialize one of the headers, based on the chapter title;
  * reset the page number.
  * @see com.itextpdf.text.pdf.PdfPageEventHelper#onChapter(
  *      com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document, float,
  *      com.itextpdf.text.Paragraph)
  */
 public override void OnChapter(
   PdfWriter writer, Document document,
   float paragraphPosition, Paragraph title)
 {
     header[1] = new Phrase(title.Content);
     pagenumber = 1;
 }
開發者ID:kuujinbo,項目名稱:iTextInAction2Ed,代碼行數:14,代碼來源:MovieHistory2.cs

示例11: Phrase

 /**
 * Copy constructor for <CODE>Phrase</CODE>.
 */
 public Phrase(Phrase phrase)
     : base()
 {
     this.AddAll(phrase);
     leading = phrase.Leading;
     font = phrase.Font;
     hyphenation = phrase.hyphenation;
 }
開發者ID:bmictech,項目名稱:iTextSharp,代碼行數:11,代碼來源:Phrase.cs

示例12: SpecialInstructions

 private static IElement SpecialInstructions(string commentsOrSpecialInstructions)
 {
     var c = new Phrase("\nCOMMENTS OR SPECIAL INSTRUCTIONS:\n", ElementFactory.StandardFontBold);
     var c1 = ElementFactory.GetPhrase(commentsOrSpecialInstructions, ElementFactory.Fonts.Standard);
     var c2 = new Phrase("\n\n\n", ElementFactory.StandardFont);
     var p = new Paragraph { c, c1, c2 };
     return p;
 }
開發者ID:HardcoreSoftware,項目名稱:iSecretary,代碼行數:8,代碼來源:ClientInfoFactory.cs

示例13: SetTable

        private void SetTable(string titleString, int year)
        {
            var ed =
               new IT.Phrase("Trofeo Luca De Gerone" + year.ToString() ,
                         IT.FontFactory.GetFont(IT.FontFactory.HELVETICA, SIZE_TITLE + 2, IT.Font.BOLD)
                         );

             var title =
               new IT.Phrase(titleString,
                         IT.FontFactory.GetFont(IT.FontFactory.HELVETICA, SIZE_TITLE, IT.Font.BOLD)
                         );
             //pett, nome ,  tempo
             float[] widths = {1f,6f,4f};
             table = new IT.pdf.PdfPTable(widths);
             table.HeaderRows = 2;
             table.DefaultCell.Border = IT.Rectangle.NO_BORDER;

             // edizione
             var cell = new IT.pdf.PdfPCell(ed);
             cell.HorizontalAlignment = IT.Element.ALIGN_CENTER;
             cell.Colspan = COLUMNS;
             cell.PaddingBottom = PAD_BOTTOM;
             table.AddCell(cell);

             // intesatazione
             cell = new IT.pdf.PdfPCell(title);
             cell.HorizontalAlignment = IT.Element.ALIGN_CENTER;
             cell.Colspan = COLUMNS;
             cell.PaddingBottom = PAD_BOTTOM;
             cell.GrayFill = 0.90F;
             table.AddCell(cell);

             // riga vuota
             //table.AddCell(GetEmptyRow());

             var data =
               new IT.Phrase("Pett.",
                         IT.FontFactory.GetFont(IT.FontFactory.HELVETICA, SIZE_ROW, IT.Font.BOLD));

             cell = new IT.pdf.PdfPCell(data);
             cell.HorizontalAlignment = IT.Element.ALIGN_LEFT;
             cell.PaddingBottom = PAD_BOTTOM;
             table.AddCell(cell);

             data = new IT.Phrase("Nome",
                         IT.FontFactory.GetFont(IT.FontFactory.HELVETICA, SIZE_ROW, IT.Font.BOLD));
             cell = new IT.pdf.PdfPCell(data);
             cell.HorizontalAlignment = IT.Element.ALIGN_LEFT;
             cell.PaddingBottom = PAD_BOTTOM;
             table.AddCell(cell);

             data = new IT.Phrase("Tempo",
                IT.FontFactory.GetFont(IT.FontFactory.HELVETICA, SIZE_ROW, IT.Font.BOLD));
             cell = new IT.pdf.PdfPCell(data);
             cell.HorizontalAlignment = IT.Element.ALIGN_RIGHT;
             cell.PaddingBottom = PAD_BOTTOM;
             table.AddCell(cell);
        }
開發者ID:o3o,項目名稱:LdgLite,代碼行數:58,代碼來源:ListBuilder.cs

示例14: fillRow

 private void fillRow(PdfPTable table) {
     for (int j = 0; j < 3; j++) {
         Phrase phrase = new Phrase("value");
         PdfPCell cell = new PdfPCell(phrase);
         cell.HorizontalAlignment = Element.ALIGN_CENTER;
         cell.VerticalAlignment = Element.ALIGN_CENTER;
         table.AddCell(cell);
     }
 }
開發者ID:newlysoft,項目名稱:itextsharp,代碼行數:9,代碼來源:TaggedPdfOnEndPageTest.cs

示例15: ClientAddress

 private static IElement ClientAddress(string clientAddress)
 {
     var p = new Phrase("\n\nTO:\n", ElementFactory.StandardFontBold);
     var p2 = new Phrase(clientAddress, ElementFactory.StandardFont);
     var x = new Paragraph() { Leading = 0, MultipliedLeading = 0.8f };
     x.Add(p);
     x.Add(p2);
     return x;
 }
開發者ID:HardcoreSoftware,項目名稱:iSecretary,代碼行數:9,代碼來源:ClientInfoFactory.cs


注:本文中的iTextSharp.text.Phrase類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。