与iTextSharp的一个句子中大胆的一个字 [英] Bold a single word within a sentence with iTextSharp

查看:120
本文介绍了与iTextSharp的一个句子中大胆的一个字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以大胆的一个词与iTextSharp的一个句子中?我想大胆的几个单独的词,而不必打破字符串转换成单独的短语。

我想这种类型超出放在

例如:原因(S)注销:见法定由$ C $反面指定C无(S)1原因(S)款

我的实际产量低于

由$ C $反面于此指定C无(S)1见法定原因(S)

例如:REASON(S)注销。

code

  pdftb4 =新PdfPTable(1);
    pdftb4.WidthPercentage = 100;
    宽度=新的浮动[1];
    宽度[0] = 0.7F;
    pdftb4.SetWidths(宽);  ;:pdfcel4 =新PdfPCell(,docBlackFont10)新词(由$ C $反面指定C无(S)项规定见Statutoryreason(S)\\ n原因(S)注销)
    pdfcel4.Border = 0;
    pdfcel4.Horizo​​ntalAlignment = Element.ALIGN_LEFT;
    pdftb4.AddCell(pdfcel4);
   objDocument.Add(pdftb4);

有人请帮助我


解决方案

完成与是你正在尝试什么方式。一个简单的例子是:

  VAR normalFont = FontFactory.GetFont(FontFactory.HELVETICA,12);
变种粗体字= FontFactory.GetFont(FontFactory.HELVETICA_BOLD,12);VAR短语=新词();
phrase.Add(新组块(的原因(S)注销,粗体字));
phrase.Add(新组块(见Statutoryreason(s)的code无(S)1反面指定本法,normalFont));

Is it possible to bold a single word within a sentence with iTextSharp? I am trying to bold several individual words without having to break the string into individual phrases.

I want to this type of out put

Eg:REASON(S) FOR CANCELLATION: See Statutory reason(s) designated by Code No(s) 1 on the reverse side hereof.

My actual output is below

Eg:REASON(S) FOR CANCELLATION: See Statutory reason(s) designated by Code No(s) 1 on the reverse side hereof.

Code

    pdftb4 = new PdfPTable(1);
    pdftb4.WidthPercentage = 100;
    width = new float[1];
    width[0] = 0.7F;
    pdftb4.SetWidths(width);

  pdfcel4 = new PdfPCell(new Phrase("\n REASON(S) FOR CANCELLATION: See Statutoryreason(s) designated by Code No(s) 1 on the reverse side hereof", docBlackFont10));
    pdfcel4.Border = 0;
    pdfcel4.HorizontalAlignment = Element.ALIGN_LEFT;
    pdftb4.AddCell(pdfcel4);
   objDocument.Add(pdftb4);

somebody please help me

解决方案

The way to accomplish what you are trying is with Chunks. A simple example is:

var normalFont = FontFactory.GetFont(FontFactory.HELVETICA, 12);
var boldFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12);

var phrase = new Phrase();
phrase.Add(new Chunk("REASON(S) FOR CANCELLATION:", boldFont));
phrase.Add(new Chunk(" See Statutoryreason(s) designated by Code No(s) 1 on the reverse side hereof", normalFont));

这篇关于与iTextSharp的一个句子中大胆的一个字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆