本文整理汇总了C#中iTextSharp.text.ListItem类的典型用法代码示例。如果您正苦于以下问题:C# ListItem类的具体用法?C# ListItem怎么用?C# ListItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListItem类属于iTextSharp.text命名空间,在下文中一共展示了ListItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: CreatePdf
// ---------------------------------------------------------------------------
/**
* Creates the PDF.
* @return the bytes of a PDF file.
*/
public byte[] CreatePdf()
{
IEnumerable<Movie> movies = PojoFactory.GetMovies(1);
using (MemoryStream ms = new MemoryStream()) {
using (Document document = new Document()) {
PdfWriter writer = PdfWriter.GetInstance(document, ms);
document.Open();
document.Add(new Paragraph(
"'Stanley Kubrick: A Life in Pictures'"
+ " is a documentary about Stanley Kubrick and his films:"
));
StringBuilder sb = new StringBuilder();
sb.AppendLine("<movies>");
List list = new List(List.UNORDERED, 20);
foreach (Movie movie in movies) {
sb.AppendLine("<movie>");
sb.AppendLine(String.Format(
"<title>{0}</title>",
XMLUtil.EscapeXML(movie.MovieTitle, true)
));
sb.AppendLine(String.Format("<year>{0}</year>", movie.Year));
sb.AppendLine(String.Format(
"<duration>{0}</duration>", movie.Duration
));
sb.AppendLine("</movie>");
ListItem item = new ListItem(movie.MovieTitle);
list.Add(item);
}
document.Add(list);
sb.Append("</movies>");
PdfFileSpecification fs = PdfFileSpecification.FileEmbedded(
writer, null, "kubrick.xml", Encoding.UTF8.GetBytes(sb.ToString())
//txt.toByteArray()
);
writer.AddFileAttachment(fs);
}
return ms.ToArray();
}
}
示例4: SetUp
virtual public void SetUp() {
LoggerFactory.GetInstance().SetLogger(new SysoLogger(3));
root = new Tag("body");
p = new Tag("p");
ul = new Tag("ul");
first = new Tag("li");
last = new Tag("li");
single = new ListItem("Single");
start = new ListItem("Start");
end = new ListItem("End");
listWithOne = new List<IElement>();
listWithTwo = new List<IElement>();
orderedUnorderedList = new OrderedUnorderedList();
CssAppliersImpl cssAppliers = new CssAppliersImpl();
orderedUnorderedList.SetCssAppliers(cssAppliers);
workerContextImpl = new WorkerContextImpl();
HtmlPipelineContext context2 = new HtmlPipelineContext(cssAppliers);
workerContextImpl.Put(typeof (HtmlPipeline).FullName, context2);
root.AddChild(p);
root.AddChild(ul);
ul.AddChild(first);
ul.AddChild(last);
p.CSS["font-size"] = "12pt";
p.CSS["margin-top"] = "12pt";
p.CSS["margin-bottom"] = "12pt";
new ParagraphCssApplier(cssAppliers).Apply(new Paragraph("paragraph"), p, context2);
first.CSS["margin-top"] = "50pt";
first.CSS["padding-top"] = "25pt";
first.CSS["margin-bottom"] = "50pt";
first.CSS["padding-bottom"] = "25pt";
last.CSS["margin-bottom"] = "50pt";
last.CSS["padding-bottom"] = "25pt";
listWithOne.Add(single);
listWithTwo.Add(start);
listWithTwo.Add(end);
}
示例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
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);
}
}
}
}
}
}
示例6: ListBody
public ListBody(ListItem parentItem, float indentation) : this(parentItem) {
this.indentation = indentation;
}
示例7: GetListItem
public static ListItem GetListItem(Properties attributes)
{
ListItem item = new ListItem(GetParagraph(attributes));
return item;
}
示例8: AddAssumptions
private void AddAssumptions(Project project, Document document)
{
if (project.Assumptions == null || project.Assumptions.Count < 1)
return;
var element = new Paragraph("Assumptions", TitleFont());
element.SpacingBefore = 5f;
document.Add(element);
var list = new List(false, false, 10);
list.SetListSymbol("\u2022");
list.IndentationLeft = 10f;
foreach (var assumption in project.Assumptions)
{
var item = new ListItem(assumption);
list.Add(item);
}
document.Add(list);
}
示例9: CreateListItem
/**
* Creates an iText Paragraph object using the properties
* of the different tags and properties in the hierarchy chain.
* @param chain the hierarchy chain
* @return a ListItem without any content
*/
public ListItem CreateListItem(ChainedProperties chain) {
ListItem item = new ListItem();
UpdateElement(item, chain);
return item;
}
示例10: ListLabel
protected internal ListLabel(ListItem parentItem) : base(parentItem)
{
role = PdfName.LBL;
indentation = 0;
}
示例11: GeneratePDFAndMail
//.........这里部分代码省略.........
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;
////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType)));
list.Add(new iTextSharp.text.ListItem(new Chunk("Follow the PlanHQ business plan wizard to produce a personalised business plan",FontType)));
list.Add(new iTextSharp.text.ListItem(new Chunk("Understand and manage the tasks associated with setting up a business",FontType)));
PdfPCell objCell = new PdfPCell();
objCell.AddElement(phrase);
objCell.AddElement(list);
objCell.AddElement(new Phrase(" "));
objCell.Colspan = 2;
pdfpTableAdditionalProductnew.AddCell(objCell);
}
if (sixteenid.Checked)
{
if (!isLastFourProductSelected)
{
// pdfDoc.NewPage();
pdfpTableAdditionalProductnew.AddCell(cellAdditionalProductnew);
isLastFourProductSelected = true;
}
PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine +Environment.NewLine +"Manage Finances", FontTypeBold));
pdfpTableAdditionalProductnew.AddCell(Cell1);
phrase = new Phrase();
phrase.Add(new Chunk("Track money coming in and out of the business?", FontTypeBold));
phrase.Add(new Chunk(" and/or",FontType));
phrase.Add(new Chunk(Environment.NewLine + "Keep track of receipts without the data entry?", FontTypeBold));
list = new iTextSharp.text.List(false, 8);
list.ListSymbol = bullet;
////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType)));
list.Add(new iTextSharp.text.ListItem(new Chunk("Saasu helps make managing and monitoring business cash flow and finances simpler and more straightforward",FontType)));
list.Add(new iTextSharp.text.ListItem(new Chunk("Receipt Bank is the quick and easy way of recording receipts and invoices. No more entering data manually – just take a photo of a receipt and send it for processing in the click of a button",FontType)));
示例12: RtfList
/**
* Constructs a new RtfList for the specified List.
*
* @param doc The RtfDocument this RtfList belongs to
* @param list The List this RtfList is based on
*/
public RtfList(RtfDocument doc, List list)
: base(doc)
{
this.listNumber = document.GetDocumentHeader().GetListNumber(this);
this.items = new ArrayList();
if (list.SymbolIndent > 0 && list.IndentationLeft > 0) {
this.firstIndent = (int) (list.SymbolIndent * RtfElement.TWIPS_FACTOR * -1);
this.leftIndent = (int) ((list.IndentationLeft + list.SymbolIndent) * RtfElement.TWIPS_FACTOR);
} else if (list.SymbolIndent > 0) {
this.firstIndent = (int) (list.SymbolIndent * RtfElement.TWIPS_FACTOR * -1);
this.leftIndent = (int) (list.SymbolIndent * RtfElement.TWIPS_FACTOR);
} else if (list.IndentationLeft > 0) {
this.firstIndent = 0;
this.leftIndent = (int) (list.IndentationLeft * RtfElement.TWIPS_FACTOR);
} else {
this.firstIndent = 0;
this.leftIndent = 0;
}
this.rightIndent = (int) (list.IndentationRight * RtfElement.TWIPS_FACTOR);
this.symbolIndent = (int) ((list.SymbolIndent + list.IndentationLeft) * RtfElement.TWIPS_FACTOR);
this.numbered = list.IsNumbered();
for (int i = 0; i < list.Items.Count; i++) {
try {
IElement element = (IElement) list.Items[i];
if (element.Type == Element.CHUNK) {
element = new ListItem((Chunk) element);
}
if (element is ListItem) {
this.alignment = ((ListItem) element).Alignment;
}
IRtfBasicElement rtfElement = doc.GetMapper().MapElement(element);
if (rtfElement is RtfList) {
((RtfList) rtfElement).SetListNumber(listNumber);
((RtfList) rtfElement).SetListLevel(listLevel + 1);
((RtfList) rtfElement).SetParent(this);
} else if (rtfElement is RtfListItem) {
((RtfListItem) rtfElement).SetParent(this);
((RtfListItem) rtfElement).InheritListSettings(listNumber, listLevel + 1);
}
items.Add(rtfElement);
} catch (DocumentException ) {
}
}
if (this.listLevel == 0) {
CorrectIndentation();
}
fontNumber = new ST.RtfFont(document, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL, new Color(0, 0, 0)));
fontBullet = new ST.RtfFont(document, new Font(Font.SYMBOL, 10, Font.NORMAL, new Color(0, 0, 0)));
}
示例13: RtfListItem
/**
* Constructs a RtfListItem for a ListItem belonging to a RtfDocument.
*
* @param doc The RtfDocument this RtfListItem belongs to.
* @param listItem The ListItem this RtfListItem is based on.
*/
public RtfListItem(RtfDocument doc, ListItem listItem)
: base(doc, listItem)
{
}
示例14: AddList
private float AddList(string[] chunks, iTextSharp.text.Font font, float spacingBefore, float spacingAfter, float spacingBetween, int alignment, float lineHightMultiplier, string listSymbol, int padding, float indentationLeft, Document doc)
{
int count = 0;
float height = 0;
float fontSize = font.Size * lineHightMultiplier;
var paragraph = new Paragraph();
var list = new List(List.UNORDERED);
list.SetListSymbol(listSymbol.PadRight(padding));
list.IndentationLeft = indentationLeft;
foreach (string item in chunks)
{
if (string.IsNullOrEmpty(item)) continue;
var chunk = new Chunk(item, font);
chunk.setLineHeight(font.Size * lineHightMultiplier);
var listItem = new ListItem(chunk);
listItem.SpacingBefore = spacingBetween;
list.Add(listItem);
count++;
}
if (count > 0)
{
paragraph.Add(list);
paragraph.Alignment = alignment;
paragraph.SpacingBefore = spacingBefore;
paragraph.SpacingAfter = spacingAfter;
doc.Add(paragraph);
height = spacingBefore + spacingAfter + count * (fontSize + spacingBetween) - spacingBetween;
}
return height;
}
示例15: GeneratePDF1
//.........这里部分代码省略.........
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;
//Used to checked Last Five product is selected
bool isLastFiveProductSelected = false;
if (get.Contains("f"))
{
// pdfDoc.NewPage();
pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct);
isLastFiveProductSelected = true;
PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "EFTPOS and merchant facilities", FontTypeBold));
pdfpTableAdditionalProduct.AddCell(Cell1);
phrase = new Phrase();
phrase.Add(new Chunk("Customers being able to pay with a debit card?", FontTypeBold));
phrase.Add(new Chunk(" and/or", FontType));
phrase.Add(new Chunk(Environment.NewLine + "Customers being able to pay with a credit card?", FontTypeBold));
list = new iTextSharp.text.List(false, 8);
list.ListSymbol = bullet;
////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType)));
list.Add(new iTextSharp.text.ListItem(new Chunk("To accept debit and credit cards from customers, whether it’s in person, over the phone or online, St.George has a range of EFTPOS and merchant solutions", FontType)));
list.Add(new iTextSharp.text.ListItem(new Chunk("Get same-day settlement (when the terminal is settled before 9pm Sydney time) on debit and credit card sales, 7 days a week, when linked to a St.George business transaction account", FontType)));
PdfPCell objCell = new PdfPCell();
objCell.AddElement(phrase);
objCell.AddElement(list);
objCell.AddElement(new Phrase(" "));
objCell.Colspan = 2;
pdfpTableAdditionalProduct.AddCell(objCell);
}
if (get.Contains("g"))
{
if (!isLastFiveProductSelected)
{
//pdfDoc.NewPage();
pdfpTableAdditionalProduct.AddCell(cellAdditionalProduct);
isLastFiveProductSelected = true;
}
PdfPCell Cell1 = new PdfPCell(new Phrase(Environment.NewLine + Environment.NewLine + "Equipment finance", FontTypeBold));
pdfpTableAdditionalProduct.AddCell(Cell1);
phrase = new Phrase();
phrase.Add(new Chunk("Purchasing a vehicle?", FontTypeBold));
phrase.Add(new Chunk(" and/or", FontType));
phrase.Add(new Chunk(Environment.NewLine + "Purchasing equipment or machinery?", FontTypeBold));
list = new iTextSharp.text.List(false, 8);
list.ListSymbol = bullet;
////////list.Add(new iTextSharp.text.ListItem(new Chunk("With this account, all day-to-day electronic transactions are fee-free",FontType)));
list.Add(new iTextSharp.text.ListItem(new Chunk("Finance up to 100% of the purchase price for vehicles or equipment", FontType)));
list.Add(new iTextSharp.text.ListItem(new Chunk("Frees up money to run a business, rather than tying up working capital", FontType)));