本文整理汇总了C#中iTextSharp.text.Phrase.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Phrase.Add方法的具体用法?C# Phrase.Add怎么用?C# Phrase.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iTextSharp.text.Phrase
的用法示例。
在下文中一共展示了Phrase.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParaCommonInfoAllBold
public static Paragraph ParaCommonInfoAllBold(string field, string value)
{
Paragraph pr = new Paragraph();
Phrase phr = new Phrase();
Chunk chk1 = new Chunk(field, FontConfig.BoldFont);
Chunk chk2 = new Chunk(value, FontConfig.BoldFont);
phr.Add(chk1);
phr.Add(chk2);
pr.Add(phr);
return pr;
}
示例2: AddRow
public void AddRow(PdfPTable t, string fname, string lname, string phone, int pid)
{
var bc = new Barcode39();
bc.X = 1.2f;
bc.Font = null;
bc.Code = pid.ToString();
var img = bc.CreateImageWithBarcode(dc, null, null);
var p1 = new Phrase();
p1.Add(new Chunk(img, 0, 0));
p1.Add(new Phrase("\n\n" + fname + " " + lname + " (" + pid + ")", smallfont));
var c = new PdfPCell(p1);
c.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
c.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
c.Border = PdfPCell.NO_BORDER;
c.FixedHeight = H * 72f;
var t2 = new PdfPTable(2);
t2.WidthPercentage = 100f;
t2.DefaultCell.Border = PdfPCell.NO_BORDER;
var cc = new PdfPCell(new Phrase(fname, font));
cc.Border = PdfPCell.NO_BORDER;
cc.Colspan = 2;
t2.AddCell(cc);
cc = new PdfPCell(new Phrase(lname, font));
cc.Border = PdfPCell.NO_BORDER;
cc.Colspan = 2;
t2.AddCell(cc);
var pcell = new PdfPCell(new Phrase(pid.ToString(), smallfont));
pcell.Border = PdfPCell.NO_BORDER;
pcell.HorizontalAlignment = Element.ALIGN_LEFT;
t2.AddCell(pcell);
pcell = new PdfPCell(new Phrase(phone.FmtFone(), smallfont));
pcell.Border = PdfPCell.NO_BORDER;
pcell.HorizontalAlignment = Element.ALIGN_RIGHT;
t2.AddCell(pcell);
var cell = new PdfPCell(t2);
cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
cell.PaddingLeft = 8f;
cell.PaddingRight = 8f;
cell.Border = PdfPCell.NO_BORDER;
cell.FixedHeight = H * 72f;
t.AddCell(c);
t.AddCell("");
t.AddCell(cell);
t.AddCell("");
t.AddCell(cell);
}
示例3: CreateSectionDetail
protected PdfPTable CreateSectionDetail()
{
Section section = GetCurrentSection();
PdfPTable nestedTable = null;
if (section.Type == WebConstants.SectionTypes.MULTIPLE_SELECT_LIST)
{
textCount++;
nestedTable = new PdfPTable(section.RepeatColumns);
nestedTable.DefaultCell.Border = Rectangle.NO_BORDER;
nestedTable.WidthPercentage = 100;
int index = 0;
int limit = section.Details.Count/section.RepeatColumns;
if(section.Details.Count%section.RepeatColumns != 0)
{
limit++;
}
for (int i = 0; i < section.RepeatColumns ; i++)
{
Phrase phrase = new Phrase();
for(int j=0; j < limit && index < section.Details.Count;j++)
{
if (j > 0)
{
phrase.Add(new Chunk("\n"));
}
if (section.Details[index].Selected)
{
phrase.Add(new Chunk(AddCheckedCheckBox(),0,0));
}
else
{
phrase.Add(new Chunk(AddCheckBox(), 0, 0));
}
//phrase.Add(new Chunk(" " + section.Details[index].Text));
phrase.Add(new Chunk(" " + section.Details[index].Text, FontFactory.GetFont("Arial", 9)));
index++;
}
nestedTable.AddCell(phrase);
}
}
else
{
nestedTable = new PdfPTable(1);
}
return nestedTable;
}
示例4: 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);
}
}
示例5: 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);
}
}
}
示例6: 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));
}
}
}
示例7: CreateDetailTitleCell
private static PdfPCell CreateDetailTitleCell(String text)
{
PdfPCell cell = new PdfPCell(new Phrase(text));
Phrase phrase = new Phrase();
phrase.Font = FontFactory.GetFont(FontFactory.HELVETICA, 9f, Font.UNDERLINE);
phrase.Add(new Phrase(text));
cell.Phrase = phrase;
cell.BorderWidth = 0;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
cell.Colspan = 3;
return cell;
}
示例8: AddCell
public bool AddCell(PdfPTable t, string desc, int code)
{
var bc = new Barcode39();
bc.X = 1.2f;
bc.Font = null;
bc.Code = code.ToString();
var img = bc.CreateImageWithBarcode(dc, null, null);
var p = new Phrase();
p.Add(new Chunk(img, 0, 0));
p.Add(new Phrase("\n" + code.ToString().Insert(3," "), font));
p.Add(new Phrase("\n" + desc, smallfont));
var c = new PdfPCell(p);
c.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
c.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
c.Border = PdfPCell.NO_BORDER;
c.FixedHeight = H * 72f;
t.AddCell(c);
n++;
if (n % 3 > 0)
t.AddCell("");
return n % 3 == 0;
}
示例9: GetLabelCell
public PdfPCell GetLabelCell()
{
// Create a new Phrase and add the image to it
var cellContent = new Phrase();
foreach (var img in _images)
{
var pdfImg = iTextSharp.text.Image.GetInstance(img);
cellContent.Add(new Chunk(pdfImg, 0, 0));
}
foreach (var txt in _textChunks)
{
var font = FontFactory.GetFont(txt.FontName, BaseFont.CP1250, txt.EmbedFont, txt.FontSize, txt.FontStyle);
cellContent.Add(new Chunk("\n" + txt.Text, font));
}
//Create a new cell specifying the content
var cell = new PdfPCell(cellContent);
cell.HorizontalAlignment = (int)_hAlign;
cell.VerticalAlignment = Element.ALIGN_TOP;
return cell;
}
示例10: PrintDealers
private void PrintDealers(int stateId, string[] bookIds)
{
DataTable dealers = TaxController.GetDealersForPdf(stateId, bookIds);
foreach (DataRow row in dealers.Rows)
{
_dealerMachineCostAmount = 0.0m;
_dealerTaxableAmount = 0.0m;
_dealerTaxAmount = 0.0m;
int dealerId = Convert.ToInt32(row[VwTax.Columns.DealerId]);
String dealerName = Convert.ToString(row[VwTax.Columns.DealerName]).ToUpper();
PdfPCell dealerCell = new PdfPCell();
dealerCell.Colspan = COLUMN_COUNT;
Phrase phrase = new Phrase();
phrase.Font = FontFactory.GetFont(FontFactory.TIMES_BOLD, 10f, Font.NORMAL);
phrase.Add(dealerName);
dealerCell.Phrase = phrase;
_table.AddCell(dealerCell);
DataTable lineItems = TaxController.GetItemsToPay(stateId, bookIds, dealerId);
foreach (DataRow lineItem in lineItems.Rows)
PrintSingleItem(lineItem);
_table.AddCell(CreateCell("Totals", Element.ALIGN_LEFT));
_table.AddCell(CreateBlankCell());
_table.AddCell(CreateBlankCell());
_table.AddCell(CreateSummaryCell(_dealerMachineCostAmount));
_table.AddCell(CreateSummaryCell(_dealerTaxableAmount));
_table.AddCell(CreateBlankCell());
_table.AddCell(CreateSummaryCell(_dealerTaxAmount));
_table.AddCell(CreateBlankRow());
}
}
示例11: OnStartPage
public void OnStartPage(PdfWriter writer, Document document)
{
var pessoaJuridica = empresa.Pessoa as IPessoaJuridica;
Chunk imagem;
if (!string.IsNullOrEmpty(pessoaJuridica.Logomarca))
{
var imghead = iTextSharp.text.Image.GetInstance(HttpContext.Current.Server.MapPath(pessoaJuridica.Logomarca));
imagem = new Chunk(imghead, 0, 0);
}
else
imagem = new Chunk("");
var dadosEmpresa = new Phrase();
dadosEmpresa.Add(pessoaJuridica.NomeFantasia + Environment.NewLine);
if (pessoaJuridica.Enderecos.Count > 0)
{
var endereco = pessoaJuridica.Enderecos[0];
dadosEmpresa.Add(endereco.ToString());
}
if (pessoaJuridica.Telefones.Count > 0)
{
var telefone = pessoaJuridica.Telefones[0];
dadosEmpresa.Add("Telefone " + telefone);
}
var tabelaHeader = new Table(2);
tabelaHeader.Border = 0;
tabelaHeader.Width = 100;
var cell = new Cell(new Phrase(imagem));
cell.Border = 0;
cell.Width = 30;
tabelaHeader.AddCell(cell);
var cell1 = new Cell(dadosEmpresa);
cell1.Border = 0;
cell1.Width = 70;
tabelaHeader.AddCell(cell1);
var linhaVazia = new Cell(new Phrase("\n", font2));
linhaVazia.Colspan = 2;
linhaVazia.DisableBorderSide(1);
tabelaHeader.AddCell(linhaVazia);
document.Add(tabelaHeader);
// Adicionando linha que informa o número da revista
var tabelaNumeroDaRevista = new Table(1);
tabelaNumeroDaRevista.Border = 0;
tabelaNumeroDaRevista.Width = 100;
var celulaNumeroDaRevista = new Cell(new Phrase("Processos de clientes publicados na revista de marcas: " + _numeroDaRevistaSelecionada, font3));
celulaNumeroDaRevista.Border = 0;
celulaNumeroDaRevista.Width = 70;
celulaNumeroDaRevista.Colspan = 1;
tabelaNumeroDaRevista.AddCell(celulaNumeroDaRevista);
var linhaVaziaNumeroRevista = new Cell(new Phrase("\n", font2));
linhaVaziaNumeroRevista.Border = 0;
linhaVaziaNumeroRevista.Width = 70;
linhaVaziaNumeroRevista.Colspan = 1;
linhaVaziaNumeroRevista.DisableBorderSide(1);
tabelaNumeroDaRevista.AddCell(linhaVaziaNumeroRevista);
document.Add(tabelaNumeroDaRevista);
}
开发者ID:ViniciusConsultor,项目名称:petsys,代码行数:76,代码来源:GeradorDeRelatorioDeProcessosDeMarcasPublicacoesProprias.cs
示例12: AddRow
private void AddRow(PdfPTable t, MemberInfo p, BaseColor color)
{
t.DefaultCell.BackgroundColor = color;
var ph = new Phrase();
ph.Add(new Chunk(p.Name, font));
ph.Add(new Chunk($"\n ({p.PeopleId})", smallfont));
t.AddCell(ph);
var sb = new StringBuilder();
AddLine(sb, p.Address);
AddLine(sb, p.Address2);
AddLine(sb, p.CityStateZip);
AddPhone(sb, p.HomePhone, "h ");
if ((p.Age ?? 0) <= 18 && p.Parents != null)
{
var a = p.Parents.Replace(", c ", "|c ").Split('|');
foreach (var li in a)
AddLine(sb, li);
}
else
AddPhone(sb, p.CellPhone, "c ");
t.AddCell(new Phrase(sb.ToString(), font));
sb = new StringBuilder();
AddLine(sb, p.MemberStatus);
AddLine(sb, p.FamMemberThis ? "Family member is member here" : "");
AddLine(sb, p.ActiveOther ? "Active in another church" : "Not Active in another church");
t.AddCell(new Phrase(sb.ToString(), font));
t.AddCell(new Phrase(p.MemberType, font));
t.AddCell(new Phrase(p.Medical, font));
}
示例13: GiveHeaderParagraph
private static Paragraph GiveHeaderParagraph(this DataSection ds)
{
var widths = ds.ColumnWidths.ToArray();
var splitted = ds.ColumnHeaders.Select((s, i) =>
{
return s.Length > widths[i] ?
s.Split(new char[] { ' ' }, StringSplitOptions.None).ToList() :
(new[] { s }).ToList();
}).ToList();
int maxLength = splitted.Max(arr => arr.Count);
splitted.ForEach(arr =>
{
while (arr.Count < maxLength)
{
arr.Insert(0, "");
}
});
Paragraph pg = new Paragraph();
pg.SpacingBefore = TextSharpFonts.DataBoldFont.Size;
pg.Leading = TextSharpFonts.DataBoldFont.Size;
for (int i = 0; i < maxLength; i++)
{
Phrase p = new Phrase();
for (int j = 0; j < splitted.Count; j++)
{
p.Add(new Chunk(splitted[j][i].Center(widths[j]), TextSharpFonts.DataBoldFont));
}
p.Add(Chunk.NEWLINE);
pg.Add(p);
}
return pg;
}
示例14: GetElements
public static IEnumerable<IElement> GetElements(this DataSection ds)
{
var elems = new List<IElement>();
// header, if needed
if (ds.ColumnHeaders.Any())
{
elems.Add(ds.GiveHeaderParagraph());
}
// process rows
foreach (IEnumerable<string> ies in ds.Rows)
{
// process items
Phrase p = new Phrase();
p.Leading = TextSharpFonts.DataFont.Size * 1.1f;
int j = 0;
foreach (string s in ies)
{
p.Add(new Chunk(s.Center(ds.ColumnWidths.ToArray()[j]), TextSharpFonts.DataFont));
j++;
}
p.Add(Chunk.NEWLINE);
elems.Add(p);
}
return elems;
}
示例15: GeneratePDF1
private void GeneratePDF1()
{
log4net.ILog log = log4net.LogManager.GetLogger("ServiceRowDataBound");
log4net.Config.XmlConfigurator.Configure();
try
{
/*CustomSessionClass objCustomSessionClass = new CustomSessionClass();
System.Web.UI.HtmlControls.HtmlTable objtbl = objCustomSessionClass._Session;
*/
System.Web.UI.HtmlControls.HtmlTable objtbl = (System.Web.UI.HtmlControls.HtmlTable)Cache["table"];
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "inline;filename=results.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
//tblBusinessBankingOnline.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 7f, 7f, 7f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
//Set Header
//iTextSharp.text.Image imgStlogo = iTextSharp.text.Image.GetInstance(iTextSharp.text.Image.GetInstance(Server.MapPath(@"StG_Master_Logo_RGBold.jpg")));
//imgStlogo.SetAbsolutePosition(0, pdfDoc.PageSize.Height - imgStlogo.Height);
//imgStlogo.ScaleToFit(200f, 90f);
//imgStlogo.SetAbsolutePosition(0, 750f);
// pdfDoc.Add(imgStlogo);
//
iTextSharp.text.Image imgStlogo = iTextSharp.text.Image.GetInstance(iTextSharp.text.Image.GetInstance(Server.MapPath(@"StG_Master_Logo_RGBold.jpg")));
PdfPTable pdfTable = new PdfPTable(1);
// pdfTable.DefaultCell.Border = Rectangle.NO_BORDER;
// pdfTable.SplitRows = false;
imgStlogo.ScaleToFit(183f, 66f);
PdfPCell imageCell = new PdfPCell(imgStlogo);
imageCell.Border = 0;
pdfTable.AddCell(imageCell);
pdfTable.HorizontalAlignment = Element.ALIGN_LEFT;
pdfDoc.Add(pdfTable);
pdfDoc.Add(new Paragraph(""));
/* pdfDoc.Add(new Paragraph(" "));
pdfDoc.Add(new Paragraph(" "));
pdfDoc.Add(new Paragraph(" "));*/
iTextSharp.text.Font font18 = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8);
iTextSharp.text.Chunk bullet = new iTextSharp.text.Chunk("\u2022", font18);
iTextSharp.text.List list = new iTextSharp.text.List(false, 4); // true= ordered, false= unordered
iTextSharp.text.List list1 = new iTextSharp.text.List(false, 4); // true= ordered, false= unordered
string amt = "8";
string atm = "Freedom Business Account";
var get = Request.QueryString["item"];
var phrase = new Phrase();
string strTextData = Environment.NewLine + "Thank you for completing the Business Account Selector tool. You’ll find your results below."
+ Environment.NewLine + "We understand that no two businesses are the same and we want to help you make the right decisions for your business to be successful."
+ Environment.NewLine + "Like every great relationship, it starts with a conversation. So if you have any questions or want to take the next steps:" + Environment.NewLine;
iTextSharp.text.Font FontTypeBold = FontFactory.GetFont("Arial", 8f, iTextSharp.text.Font.BOLD);
iTextSharp.text.Font FontTypeBoldlarge = FontFactory.GetFont("Arial", 10f, iTextSharp.text.Font.BOLD);
iTextSharp.text.Font FontType = FontFactory.GetFont("Arial", 8f, iTextSharp.text.Font.NORMAL);
iTextSharp.text.Font FontTypeSmall = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL);
phrase = new Phrase();
phrase.Add(new Chunk("Business Account and Product Selector Results", FontTypeBoldlarge));
phrase.Add(new Chunk(Environment.NewLine + "Hello " + Request.QueryString["Name"], FontTypeBold));
phrase.Add(new Chunk(strTextData, FontType));
pdfDoc.Add(phrase);
PdfPTable tblCall = new PdfPTable(1);
tblCall.WidthPercentage = 30f;
tblCall.HorizontalAlignment = Element.ALIGN_LEFT;
tblCall.DefaultCell.Border = Rectangle.NO_BORDER;
iTextSharp.text.Image imgCall = iTextSharp.text.Image.GetInstance(iTextSharp.text.Image.GetInstance(Server.MapPath(@"pdfCTA-1.png")));
tblCall.AddCell(imgCall);
pdfDoc.Add(tblCall);
phrase = new Phrase();
phrase.Add(new Chunk("To find out what information is needed to become a customer, visit ", FontType));
pdfDoc.Add(phrase);
Font link = FontFactory.GetFont("Arial", 8, Font.UNDERLINE, new Color(0, 0, 255));
Anchor anchor = new Anchor("http://www.stgeorge.com.au/idchecklist", link);
anchor.Reference = "http://www.stgeorge.com.au/idchecklist";
pdfDoc.Add(anchor);
pdfDoc.Add(new Phrase(Environment.NewLine + Environment.NewLine, FontType));
#region CodeForLastFiveProduct
PdfPTable pdfpTableAdditionalProduct = new PdfPTable(2);
pdfpTableAdditionalProduct.WidthPercentage = 100f;
int[] TableAdditionalProductwidth = { 30, 70 };
pdfpTableAdditionalProduct.SetWidths(TableAdditionalProductwidth);
phrase = new Phrase(" " + Environment.NewLine);
phrase.Add(new Chunk("Business Products", FontTypeBold));
phrase.Add(Environment.NewLine + " ");
PdfPCell cellAdditionalProduct = new PdfPCell(phrase);
cellAdditionalProduct.Colspan = 3;
//.........这里部分代码省略.........