• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# text.Font类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Font类属于iTextSharp.text命名空间,在下文中一共展示了Font类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GenerateRow

        private static void GenerateRow(PdfPTable table, PlayerInfo player, Font font, BaseColor backgroundColor)
        {
            var jpg = Image.GetInstance(player.PictureUrl);
            table.AddCell(jpg);

            PdfPCell cell;

            cell = new PdfPCell(new Phrase(player.JerseyNumber, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase(player.Name, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);

            if (table.NumberOfColumns == NumberColsWithPosition)
            {
                cell = new PdfPCell(new Phrase(player.Position, font)) {BackgroundColor = backgroundColor};
                table.AddCell(cell);
            }

            cell = new PdfPCell(new Phrase(player.Height, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase(player.Weight, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase(player.DateOfBirth, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase(player.Age, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase(player.BirthPlace, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);
        }
开发者ID:ColinStranc,项目名称:MockDraftAnalysis,代码行数:34,代码来源:PdfGenerator.cs


示例2: Write

        public void Write(string outputPath, FlowDocument doc)
        {
            Document pdfDoc = new Document(PageSize.A4, 50, 50, 50, 50);
            Font textFont = new Font(baseFont, DEFAULT_FONTSIZE, Font.NORMAL, BaseColor.BLACK);
            Font headingFont = new Font(baseFont, DEFAULT_HEADINGSIZE, Font.BOLD, BaseColor.BLACK);
            using (FileStream stream = new FileStream(outputPath, FileMode.Create))
            {
                PdfWriter writer = PdfWriter.GetInstance(pdfDoc, stream);
                pdfDoc.Open();
                foreach (Block i in doc.Blocks) {
                    if (i is System.Windows.Documents.Paragraph)
                    {
                        TextRange range = new TextRange(i.ContentStart, i.ContentEnd);
                        Console.WriteLine(i.Tag);
                        switch (i.Tag as string)
                        {
                            case "Paragraph": iTextSharp.text.Paragraph par = new iTextSharp.text.Paragraph(range.Text, textFont);
                                par.Alignment = Element.ALIGN_JUSTIFIED;
                                              pdfDoc.Add(par);
                                              break;
                            case "Heading": iTextSharp.text.Paragraph head = new iTextSharp.text.Paragraph(range.Text, headingFont);
                                              head.Alignment = Element.ALIGN_CENTER;
                                              head.SpacingAfter = 10;
                                              pdfDoc.Add(head);
                                              break;
                            default:          iTextSharp.text.Paragraph def = new iTextSharp.text.Paragraph(range.Text, textFont);
                                              def.Alignment = Element.ALIGN_JUSTIFIED;
                                              pdfDoc.Add(def);
                                              break;

                        }
                    }
                    else if (i is System.Windows.Documents.List)
                    {
                        iTextSharp.text.List list = new iTextSharp.text.List(iTextSharp.text.List.UNORDERED, 10f);
                        list.SetListSymbol("\u2022");
                        list.IndentationLeft = 15f;
                        foreach (var li in (i as System.Windows.Documents.List).ListItems)
                        {
                            iTextSharp.text.ListItem listitem = new iTextSharp.text.ListItem();
                            TextRange range = new TextRange(li.Blocks.ElementAt(0).ContentStart, li.Blocks.ElementAt(0).ContentEnd);
                            string text = range.Text.Substring(1);
                            iTextSharp.text.Paragraph par = new iTextSharp.text.Paragraph(text, textFont);
                            listitem.SpacingAfter = 10;
                            listitem.Add(par);
                            list.Add(listitem);
                        }
                        pdfDoc.Add(list);
                    }

               }
                if (pdfDoc.PageNumber == 0)
                {
                    iTextSharp.text.Paragraph par = new iTextSharp.text.Paragraph(" ");
                    par.Alignment = Element.ALIGN_JUSTIFIED;
                    pdfDoc.Add(par);
                }
               pdfDoc.Close();
            }
        }
开发者ID:drdaemos,项目名称:ODTCONVERTvs10,代码行数:60,代码来源:PDFWriter.cs


示例3: BaseFontAndSize

 // 函数描述:设置字体的样式
 public static Font BaseFontAndSize(string fontName, int size, int style, BaseColor baseColor)
 {
     BaseFont.AddToResourceSearch("iTextAsian.dll");
     BaseFont.AddToResourceSearch("iTextAsianCmaps.dll");
     string fileName;
     switch (fontName)
     {
         case "黑体":
             fileName = "SIMHEI.TTF";
             break;
         case "华文中宋":
             fileName = "STZHONGS.TTF";
             break;
         case "宋体":
             fileName = "simsun_1.ttf";
             break;
         default:
             fileName = "simsun_1.ttf";
             break;
     }
     var baseFont = BaseFont.CreateFont(@"c:/windows/fonts/" + fileName, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
     var fontStyle = style < -1 ? Font.NORMAL : style;
     var font = new Font(baseFont, size, fontStyle, baseColor);
     return font;
 }
开发者ID:GankerChen2012,项目名称:PdfTools,代码行数:26,代码来源:ExamAnalysiseReportFormat.cs


示例4: ManipulatePdf

// ---------------------------------------------------------------------------    
    /**
     * Manipulates a PDF file src with the file dest as result
     * @param src the original PDF
     */
    public byte[] ManipulatePdf(byte[] src) {
    // Create a table with named actions
      Font symbol = new Font(Font.FontFamily.SYMBOL, 20);
      PdfPTable table = new PdfPTable(4);
      table.DefaultCell.Border = Rectangle.NO_BORDER;
      table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
      Chunk first = new Chunk( ((char)220).ToString() , symbol);
      first.SetAction(new PdfAction(PdfAction.FIRSTPAGE));
      table.AddCell(new Phrase(first));
      Chunk previous = new Chunk( ((char)172).ToString(), symbol);
      previous.SetAction(new PdfAction(PdfAction.PREVPAGE));
      table.AddCell(new Phrase(previous));
      Chunk next = new Chunk( ((char)174).ToString(), symbol);
      next.SetAction(new PdfAction(PdfAction.NEXTPAGE));
      table.AddCell(new Phrase(next));
      Chunk last = new Chunk( ((char)222).ToString(), symbol);
      last.SetAction(new PdfAction(PdfAction.LASTPAGE));
      table.AddCell(new Phrase(last));
      table.TotalWidth = 120;
      
      // Create a reader
      PdfReader reader = new PdfReader(src);
      using (MemoryStream ms = new MemoryStream()) {
        // Create a stamper
        using (PdfStamper stamper = new PdfStamper(reader, ms)) {
          // Add the table to each page
          PdfContentByte canvas;
          for (int i = 0; i < reader.NumberOfPages; ) {
            canvas = stamper.GetOverContent(++i);
            table.WriteSelectedRows(0, -1, 696, 36, canvas);
          }
        }
        return ms.ToArray();
      }    
    }    
开发者ID:,项目名称:,代码行数:40,代码来源:


示例5: Write

 // ---------------------------------------------------------------------------
 public void Write(Stream stream)
 {
     // step 1
     using (Document document = new Document())
     {
         // step 2
         PdfWriter.GetInstance(document, stream);
         // step 3
         document.Open();
         // step 4
         BaseFont bf;
         Font font;
         for (int i = 0; i < 3; i++)
         {
             bf = BaseFont.CreateFont(
               MOVIES[i][0], MOVIES[i][1], BaseFont.NOT_EMBEDDED
             );
             font = new Font(bf, 12);
             document.Add(new Paragraph(bf.PostscriptFontName, font));
             for (int j = 2; j < 5; j++)
             {
                 document.Add(new Paragraph(MOVIES[i][j], font));
             }
             document.Add(Chunk.NEWLINE);
         }
     }
 }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:28,代码来源:CJKExample.cs


示例6: PopulateDocument

        protected override void PopulateDocument()
        {
            var bfCourier = BaseFont.CreateFont(BaseFont.COURIER, BaseFont.CP1252, false);
            var courier = new Font(bfCourier, 12, Font.ITALIC, BaseColor.RED);

            Document.Add(new Paragraph(string.Format("It did. {0}", DateTime.Now), courier));
        }
开发者ID:ColinStranc,项目名称:MockDraftAnalysis,代码行数:7,代码来源:PdfSample5.cs


示例7: NamedFont

 NamedFont(string name, Font font)
 {
     if (name =="" || font == null)
         throw new InvalidParameterException();
     Font = font;
     _name = name;
 }
开发者ID:Jazzuell,项目名称:parser,代码行数:7,代码来源:NamedFont.cs


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


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


示例10: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.Filter = "*.pdf|*.PDF";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                var doc = new Document();
                BaseFont baseFont = BaseFont.CreateFont(@"TIMES.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

                iTextSharp.text.Font zag = new iTextSharp.text.Font(baseFont, 16, iTextSharp.text.Font.BOLD);
                iTextSharp.text.Font curs = new iTextSharp.text.Font(baseFont, 14, iTextSharp.text.Font.ITALIC);
                iTextSharp.text.Font other_text = new iTextSharp.text.Font(baseFont, 12, iTextSharp.text.Font.BOLD);
                iTextSharp.text.Font othtext = new iTextSharp.text.Font(baseFont, 12, iTextSharp.text.Font.NORMAL);
                PdfWriter.GetInstance(doc, new FileStream(@saveFileDialog1.FileName, FileMode.Create));
                doc.Open();

                Paragraph par = new Paragraph("Акт закупок", zag);
                par.Alignment = Element.ALIGN_CENTER;
                Paragraph variant = new Paragraph("Аптека № 10", curs);
                variant.Alignment = Element.ALIGN_RIGHT;
                Paragraph otstup = new Paragraph("\r\n");
                doc.Add(par);

                doc.Add(otstup);
                PdfPTable table = new PdfPTable(5);

                PdfPCell cell1 = new PdfPCell(new Phrase("№", other_text));
                PdfPCell cell2 = new PdfPCell(new Phrase("Препарат", other_text));
                PdfPCell cell3 = new PdfPCell(new Phrase("Поставщик", other_text));
                PdfPCell cell4 = new PdfPCell(new Phrase("Количество", other_text));
                PdfPCell cell5 = new PdfPCell(new Phrase("Сумма", other_text));

                table.AddCell(cell1);
                table.AddCell(cell2);
                table.AddCell(cell3);
                table.AddCell(cell4);
                table.AddCell(cell5);

                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    for (int j = 0; j < dataGridView1.Rows[i].Cells.Count; j++)
                    {
                        if (dataGridView1.Rows[i].Cells[j].Value != null)
                        {
                            string tempS = dataGridView1.Rows[i].Cells[j].Value.ToString();

                            cell1 = new PdfPCell(new Phrase(tempS, othtext));
                            table.AddCell(cell1);
                        }
                    }
                }

                doc.Add(table);
                doc.Add(variant);
                doc.Close();

                MessageBox.Show("ok");

            }
        }
开发者ID:Geliya94,项目名称:oop,代码行数:60,代码来源:Zakaz.cs


示例11: MovieHistory

 static MovieHistory()
 {
     FONT[0] = new Font(Font.FontFamily.HELVETICA, 24);
     FONT[1] = new Font(Font.FontFamily.HELVETICA, 18);
     FONT[2] = new Font(Font.FontFamily.HELVETICA, 14);
     FONT[3] = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD);
 }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:7,代码来源:MovieHistory.cs


示例12: TestNotoFont

        public void TestNotoFont()
        {
            Document document = new Document();

            PdfAWriter writer = PdfAWriter.GetInstance(document, new MemoryStream(), PdfAConformanceLevel.PDF_A_1B);
            writer.CreateXmpMetadata();

            document.Open();
            FileStream iccProfileFileStream = File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read, FileShare.Read);
            ICC_Profile icc = ICC_Profile.GetInstance(iccProfileFileStream);
            iccProfileFileStream.Close();
            writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);

            String fontPath = RESOURCES + "NotoSansCJKjp-Bold.otf";
            BaseFont bf = BaseFont.CreateFont(fontPath, "Identity-H", true);
            Font font = new Font(bf, 14);
            String[] lines = new String[] {"Noto test", "in japanese:", "\u713C"};

            foreach (String line in lines)
            {
                document.Add(new Paragraph(line, font));
            }

            document.Close();
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:25,代码来源:PdfAFontEmbeddingTest.cs


示例13: 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,代码来源:


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


示例15: PdfArchiver

 static PdfArchiver()
 {
     BaseFont.AddToResourceSearch("iTextAsian.dll");
     _font = new Font(
        BaseFont.CreateFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", BaseFont.NOT_EMBEDDED)
        , 16);
 }
开发者ID:karino2,项目名称:wikipediaconv,代码行数:7,代码来源:PdfArchiver.cs


示例16: CreatePDF

 public bool CreatePDF(int fontSize)
 {
     Console.WriteLine(Helpers.IO.GetClassOutputPath(this));
     var font = new Font(Font.NORMAL, fontSize, 1, new BaseColor(0, 0, 0));
     var onePageDoc = new OnePageDocument();
     // GetClassOutputPath() implementation left out for brevity
     var outputFile = Helpers.IO.GetClassOutputPath(this);
     using (FileStream stream = new FileStream(
         outputFile, 
         FileMode.Create, 
         FileAccess.Write))
     {
         using (Document document = new Document())
         {
             var writer = PdfWriter.GetInstance(document, stream);
             writer.PageEvent = onePageDoc;
             document.Open();
             for (int i = 0; i < 4; ++i)
             {
                 document.Add(new Paragraph(TEST_STRING, font));
             }
         }
     }
     return onePageDoc.TotalPages > 1 ? true : false;
 } 
开发者ID:kuujinbo,项目名称:StackOverflow.iTextSharp,代码行数:25,代码来源:ReduceFont.cs


示例17: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            filePdf = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.InternetCache), "PDF_Temp.pdf");

            var document = new Document(PageSize.LETTER);

            // Create a new PdfWriter object, specifying the output stream
            var output = new FileStream(filePdf, FileMode.Create);
            var writer = PdfWriter.GetInstance(document, output);

            // Open the Document for writing
            document.Open();

            BaseFont bf = BaseFont.CreateFont (BaseFont.HELVETICA, BaseFont.CP1252, false);
            iTextSharp.text.Font font = new iTextSharp.text.Font (bf, 16, iTextSharp.text.Font.BOLD);
            var p = new Paragraph ("Sample text", font);

            document.Add (p);
            document.Close ();
            writer.Close ();

            //Close the Document - this saves the document contents to the output stream
            document.Close();
            writer.Close ();
        }
开发者ID:JamieMellway,项目名称:iTextSharpLGPL-Monotouch,代码行数:27,代码来源:iTextSharp_TestViewController.cs


示例18: Export

        public static void Export(DetailsView dvGetStudent, string imageFilePath, string filename)
        {
            int rows = dvGetStudent.Rows.Count;
            int columns = dvGetStudent.Rows[0].Cells.Count;
            int pdfTableRows = rows - 1;
            iTextSharp.text.Table PdfTable = new iTextSharp.text.Table(2, pdfTableRows);
            //PdfTable.BorderWidth = 1;
            PdfTable.Cellpadding = 0;
            PdfTable.Cellspacing = 0;
            iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageFilePath);
            jpg.Alignment = Element.ALIGN_CENTER;
            jpg.ScaleToFit(150f, 150f);
            string fontUrl = System.AppDomain.CurrentDomain.BaseDirectory + "Files\\arial.ttf";
            BaseFont STF_Helvetica_Russian = BaseFont.CreateFont(fontUrl, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            Font font = new Font(STF_Helvetica_Russian, Font.DEFAULTSIZE, Font.NORMAL);
            for (int rowCounter = 1; rowCounter < rows; rowCounter++)
            {
                for (int columnCounter = 0; columnCounter < columns; columnCounter++)
                {
                    string strValue = dvGetStudent.Rows[rowCounter].Cells[columnCounter].Text;

                    PdfTable.AddCell(new Paragraph(strValue, font));
                }
            }
            Document Doc = new Document();

            PdfWriter.GetInstance(Doc, HttpContext.Current.Response.OutputStream);
            Doc.Open();
            Doc.Add(jpg);
            Doc.Add(PdfTable);
            Doc.Close();
            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + filename + ".pdf");
            HttpContext.Current.Response.End();
        }
开发者ID:an-kir,项目名称:List-Of-Students,代码行数:35,代码来源:ExportToPdf.cs


示例19: GetFont

		/// <summary>
		/// Gets the font object.
		/// </summary>
		/// <param name="textProperties">The text properties.</param>
		/// <returns>The font object</returns>
		public static Font GetFont(TextProperties textProperties)
		{
			try
			{
				Font font = new Font();
				if (textProperties != null)
				{
					string fontName = "";
					if (textProperties.FontName != null)
						fontName = textProperties.FontName;
					else
					{
						fontName = DefaultDocumentStyles.Instance().DefaultTextFont.Familyname;
					}

					if (FontFactory.Contains(fontName))
					{
						string colorStr = "#000000";
						int iTextFontStyle = 0; //normal
						int bold = (textProperties.Bold != null && textProperties.Bold.ToLower() == "bold") ? 1 : 0;
						int italic = (textProperties.Italic != null && textProperties.Italic.ToLower() == "italic") ? 1 : 0;
						int textLineThrough = (textProperties.TextLineThrough != null) ? 1 : 0;
						int underline = (textProperties.Underline != null) ? 1 : 0;
						float size = 12.0f; // up to now, standard todo: do it better
						if (textProperties.FontSize != null)
						{
							if (textProperties.FontSize.ToLower().EndsWith("pt"))
							{
								try
								{
									size = (float) Convert.ToDouble(textProperties.FontSize.ToLower().Replace("pt",""));
								}
								catch(Exception)
								{
									throw;
								}
							}
						}
						if (textProperties.FontColor != null)
						{
							colorStr = textProperties.FontColor;
						}
						if (bold == 1 && italic == 1)
							iTextFontStyle = Font.BOLDITALIC;
						if (bold == 1 && italic == 0)
							iTextFontStyle = Font.BOLD;
						if (bold == 0 && italic == 1)
							iTextFontStyle = Font.ITALIC;
						// TODO: underline strike through
						iTextSharp.text.Color color = RGBColorConverter.GetColorFromHex(colorStr);
						font = FontFactory.GetFont(fontName, size, iTextFontStyle, color);
					}
				}
				return font;
			}
			catch(Exception)
			{
				throw;
			}
		}
开发者ID:rabidbob,项目名称:aodl-reloaded,代码行数:65,代码来源:TextPropertyConverter.cs


示例20: Build

        public void Build()
        {
            if (artUrls != null)
            {
                Build2();
                return;
            }
            Document document = new Document();
            PdfWriter.GetInstance(document, new FileStream(baseDir + _fileName, FileMode.Create));
            document.Open();
            document.AddTitle(_title);

            Font ft = new Font(baseFT, 12);

            int cnt = items.Count;

            for (int i = cnt - 1; i >= 0; i--)
            {
                var entity = items[i];
                if (!entity.IsDown)
                {
                    continue;
                }
                _callback("获取文章 " + (cnt - i) + "/" + cnt + ":" + entity.Title);

                document.Add(GetChapter(entity));
            }
            document.Close();
        }
开发者ID:kevinzhwl,项目名称:ExportBlog,代码行数:29,代码来源:PdfPackage.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# text.List类代码示例发布时间:2022-05-26
下一篇:
C# text.Document类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap