本文整理汇总了C#中iTextSharp.text.ListItem.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ListItem.Add方法的具体用法?C# ListItem.Add怎么用?C# ListItem.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iTextSharp.text.ListItem
的用法示例。
在下文中一共展示了ListItem.Add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
}
示例2: End
/* (non-Javadoc)
* @see com.itextpdf.tool.xml.ITagProcessor#endElement(com.itextpdf.tool.xml.Tag, java.util.List)
*/
public override IList<IElement> End(IWorkerContext ctx, Tag tag, IList<IElement> currentContent) {
IList<IElement> l = new List<IElement>(1);
ListItem li = new ListItem();
float maxSize = -1;
foreach (IElement e in currentContent) {
li.Add(e);
//finding max leading among list item elements
foreach (Chunk chunk in e.Chunks) {
// here we use 4f/3 multiplied leading value to simulate leading which is used with default font size
float currFontSize = chunk.Font.GetCalculatedLeading(4f/3);
if (maxSize < currFontSize) {
maxSize = currFontSize;
}
}
}
if (li.Leading < maxSize)
li.Leading = maxSize;
if (li.Trim()) {
l.Add(li); // css applying is handled in the OrderedUnorderedList Class.
}
return l;
}
示例3: PopulateList
/**
* Fills a java.util.List with all elements found in currentContent. Places elements that are not a {@link ListItem} or {@link com.itextpdf.text.List} in a new ListItem object.
*
* @param currentContent
* @return java.util.List with only {@link ListItem}s or {@link com.itextpdf.text.List}s in it.
*/
private IList<IElement> PopulateList(IList<IElement> currentContent)
{
IList<IElement> listElements = new List<IElement>();
foreach (IElement e in currentContent) {
if (e is ListItem || e is List) {
listElements.Add(e);
} else {
ListItem listItem = new ListItem();
listItem.Add(e);
listElements.Add(listItem);
}
}
return listElements;
}
示例4: 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;
//.........这里部分代码省略.........
示例5: GeneratePDFAndMail
private void GeneratePDFAndMail()
{
log4net.ILog log = log4net.LogManager.GetLogger("ServiceRowDataBound");
log4net.Config.XmlConfigurator.Configure();
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 7f, 7f, 7f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
MemoryStream memoryStream = new MemoryStream();
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream);
pdfDoc.Open();
/* iTextSharp.text.Image imgStlogo = iTextSharp.text.Image.GetInstance(iTextSharp.text.Image.GetInstance(Server.MapPath(@"StG_Master_Logo_RGB.jpg")));
imgStlogo.SetAbsolutePosition(0, pdfDoc.PageSize.Height - imgStlogo.Height);
pdfDoc.Add(imgStlogo);
pdfDoc.Add(new Paragraph(" "));
pdfDoc.Add(new Paragraph(" "));
pdfDoc.Add(new Paragraph(" "));*/
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(""));
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 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", 8f, 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 " + txtName.Text, 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 CodeFonewFourProduct
PdfPTable pdfpTableAdditionalProductnew = new PdfPTable(2);
pdfpTableAdditionalProductnew.WidthPercentage = 100f;
int[] TableAdditionalProductwidthnew = { 30, 70 };
pdfpTableAdditionalProductnew.SetWidths(TableAdditionalProductwidthnew);
phrase = new Phrase(" " + Environment.NewLine);
phrase.Add(new Chunk("My Business Connect", FontTypeBold));
phrase.Add(Environment.NewLine + " ");
PdfPCell cellAdditionalProductnew = new PdfPCell(phrase);
cellAdditionalProductnew.Colspan = 3;
//Used to checked Last Five product is selected
bool isLastFourProductSelected = false;
if (fifteenid.Checked)
{
// pdfDoc.NewPage();
pdfpTableAdditionalProductnew.AddCell(cellAdditionalProductnew);
isLastFourProductSelected = true;
PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Planning and Setup", FontTypeBold));
pdfpTableAdditionalProductnew.AddCell(Cell1);
phrase = new Phrase();
phrase.Add(new Chunk("Make a business plan?", FontTypeBold));
list = new iTextSharp.text.List(false, 8);
list.ListSymbol = bullet;
//.........这里部分代码省略.........
示例6: 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
Director director;
using (var c = AdoDB.Provider.CreateConnection())
{
c.ConnectionString = AdoDB.CS;
using (DbCommand cmd = c.CreateCommand())
{
cmd.CommandText = SQL;
c.Open();
using (var r = cmd.ExecuteReader())
{
while (r.Read())
{
// create a paragraph for the director
director = PojoFactory.GetDirector(r);
Paragraph p = new Paragraph(
PojoToElementFactory.GetDirectorPhrase(director));
// add a dotted line separator
p.Add(new Chunk(new DottedLineSeparator()));
// adds the number of movies of this director
p.Add(string.Format("movies: {0}", Convert.ToInt32(r["c"])));
document.Add(p);
// Creates a list
List list = new List(List.ORDERED);
list.IndentationLeft = 36;
list.IndentationRight = 36;
// Gets the movies of the current director
var director_id = Convert.ToInt32(r["id"]);
ListItem movieitem;
// LINQ allows us to on sort any movie object property inline;
// let's sort by Movie.Year, Movie.Title
var by_year = from m in PojoFactory.GetMovies(director_id)
orderby m.Year, m.Title
select m;
// loops over the movies
foreach (Movie movie in by_year)
{
// creates a list item with a movie title
movieitem = new ListItem(movie.MovieTitle);
// adds a vertical position mark as a separator
movieitem.Add(new Chunk(new VerticalPositionMark()));
var yr = movie.Year;
// adds the year the movie was produced
movieitem.Add(new Chunk(yr.ToString()));
// add an arrow to the right if the movie dates from 2000 or later
if (yr > 1999)
{
movieitem.Add(PositionedArrow.RIGHT);
}
// add the list item to the list
list.Add(movieitem);
}
// add the list to the document
document.Add(list);
}
}
}
}
}
}