本文整理汇总了C#中iTextSharp.text.pdf.PdfPCell类的典型用法代码示例。如果您正苦于以下问题:C# PdfPCell类的具体用法?C# PdfPCell怎么用?C# PdfPCell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PdfPCell类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfPCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteTOC
protected virtual void WriteTOC(List<PdfContentParameter> contents, PdfWriter writer, Document document)
{
document.NewPage();
PdfPTable t = new PdfPTable(2);
t.WidthPercentage = 100;
t.SetWidths(new float[] { 98f, 2f });
t.TotalWidth = document.PageSize.Width - (document.LeftMargin + document.RightMargin);
t.AddCell(new PdfPCell(
new Phrase(GlobalStringResource.TableOfContents,
FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 16))
) { Colspan = 2, Border = Rectangle.NO_BORDER, PaddingBottom = 25 });
foreach (PdfContentParameter item in contents)
{
if (!string.IsNullOrEmpty(item.Header))
{
t.AddCell(
new PdfPCell(
new Phrase(item.Header,
FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 8)
)
) { Border = Rectangle.NO_BORDER, NoWrap = false, FixedHeight = 15, }
);
PdfPCell templateCell = new PdfPCell(Image.GetInstance(item.Template));
templateCell.HorizontalAlignment = Element.ALIGN_RIGHT;
templateCell.Border = Rectangle.NO_BORDER;
t.AddCell(templateCell);
}
}
float docHeight = document.PageSize.Height - heightOffset;
document.Add(t);
}
示例2: 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);
}
示例3: CreatePdf
private void CreatePdf(FileStream outputStream)
{
var doc = new Document(PageSize.A4);
PdfWriter.GetInstance(doc, outputStream);
doc.Open();
WriteFrontPage(doc);
doc.NewPage();
WriteSpecification(doc);
foreach (var representation in _report.Representations)
{
doc.NewPage();
doc.Add(new Paragraph("Representation"));
}
PdfPTable table = new PdfPTable(2);
table.AddCell(new PdfPCell { Colspan = 1 });
PdfPCell cell = new PdfPCell { Colspan = 1, HorizontalAlignment = 1, Phrase = new Phrase("REPRESENTATIONSKOSTNADER") };
table.AddCell(cell);
table.AddCell("Col 1 Row 1");
table.AddCell("Col 2 Row 1");
table.AddCell("Col 3 Row 1");
table.AddCell("Col 1 Row 2");
table.AddCell("Col 2 Row 2");
table.AddCell("Col 3 Row 2");
doc.Add(table);
doc.Close();
}
示例4: ConfigurarConteudo
private static void ConfigurarConteudo(List<Tarefa> tarefas, Document document)
{
foreach (Tarefa tarefa in tarefas)
{
PdfPTable table = new PdfPTable(2);
PdfPCell cell = new PdfPCell(new Phrase( tarefa.ToString()));
cell.Colspan = 2;
cell.BackgroundColor = BaseColor.GRAY;
cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
table.AddCell(cell);
PdfPCell cellSubitem = new PdfPCell(new Phrase("Subitem"));
cellSubitem.BackgroundColor = BaseColor.LIGHT_GRAY;
cellSubitem.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
PdfPCell cellPercentual = new PdfPCell(new Phrase("Percentual"));
cellPercentual.BackgroundColor = BaseColor.LIGHT_GRAY;
cellPercentual.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
table.AddCell(cellSubitem);
table.AddCell(cellPercentual);
foreach (Subitem subitem in tarefa.Subitens)
{
table.AddCell(subitem.Titulo);
table.AddCell(subitem.Percentual.ToString());
}
document.Add(table);
document.Add(new Paragraph(" "));
}
}
示例5: GeneratePdfReport
public static void GeneratePdfReport(string filepath)
{
FileStream fileStream = new FileStream(filepath, FileMode.Create);
Document document = new Document();
PdfWriter writer = PdfWriter.GetInstance(document, fileStream);
document.SetPageSize(PageSize.A3);
document.Open();
var paragraph = new Paragraph("Aggregated Sales Report",
FontFactory.GetFont("Arial", 19, Font.BOLD));
paragraph.SpacingAfter = 20.0f;
paragraph.Alignment = 1;
document.Add(paragraph);
PdfPTable mainTable = new PdfPTable(1);
var reports = GetDayReports();
foreach (var dayReport in reports)
{
var headerCell = new PdfPCell(new Phrase("Date: " + dayReport.FormattedDate));
headerCell.BackgroundColor = new BaseColor(175, 166, 166);
mainTable.AddCell(headerCell);
var table = GenerateReportTable(dayReport);
mainTable.AddCell(table);
}
document.Add(mainTable);
document.Close();
}
示例6: GeneratePDFReport
// to generate the report call the GeneratePDFReport static method.
// The pdf file will be generated in the SupermarketChain.ConsoleClient folder
// TODO measures are missing
// TODO code refactoring to limitr repeated chunks
public static void GeneratePDFReport()
{
Document doc = new Document(iTextSharp.text.PageSize.A4, 10, 10, 40, 35);
string filePath = @"..\..\..\..\Reports\salesReports.pdf";
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(filePath, FileMode.Create));
doc.Open();
PdfPTable table = new PdfPTable(5);
Font verdana = FontFactory.GetFont("Verdana", 16, Font.BOLD);
Font verdana2 = FontFactory.GetFont("Verdana", 12, Font.BOLD);
PdfPCell header = new PdfPCell(new Phrase("Aggregated Sales Report", verdana));
header.Colspan = 5;
header.HorizontalAlignment = 1;
table.AddCell(header);
double totalSales = PourReportData(table);
PdfPCell totalSum = new PdfPCell(new Phrase("Grand total:"));
totalSum.Colspan = 4;
totalSum.HorizontalAlignment = 2;
totalSum.BackgroundColor = new BaseColor(161, 212, 224);
table.AddCell(totalSum);
PdfPCell totalSumNumber = new PdfPCell(new Phrase(String.Format("{0:0.00}", totalSales), verdana));
totalSumNumber.BackgroundColor = new BaseColor(161, 212, 224);
table.AddCell(totalSumNumber);
doc.Add(table);
doc.Close();
DirectoryInfo directoryInfo = new DirectoryInfo(filePath);
Console.WriteLine("Pdf report generated.");
Console.WriteLine("File: {0}", directoryInfo.FullName);
}
示例7: generatePDFButton_Click
protected void generatePDFButton_Click(object sender, EventArgs e)
{
PdfPTable pdfPTable = new PdfPTable(CreatedStudentInformationGridView.HeaderRow.Cells.Count);
foreach (TableCell headerCell in CreatedStudentInformationGridView.HeaderRow.Cells)
{
PdfPCell pfdPCell = new PdfPCell(new Phrase(headerCell.Text));
//pfdPCell.BackgroundColor = new BaseColor(newCenterGridView.HeaderStyle.ForeColor);
pdfPTable.AddCell(pfdPCell);
}
foreach (GridViewRow gridViewRow in CreatedStudentInformationGridView.Rows)
{
foreach (TableCell tableCell in gridViewRow.Cells)
{
PdfPCell pfdPCell = new PdfPCell(new Phrase(tableCell.Text));
//pfdPCell.BackgroundColor = new BaseColor(newCenterGridView.HeaderStyle.ForeColor);
pdfPTable.AddCell(pfdPCell);
}
}
Document pdfDocument = new Document(PageSize.A4, 10f, 10f, 10f, 10f);
PdfWriter.GetInstance(pdfDocument, Response.OutputStream);
pdfDocument.Open();
pdfDocument.Add(pdfPTable);
pdfDocument.Close();
Response.ContentType = "application/pdf";
Response.AppendHeader("content-disposition", "attachment;filename=NewCenter.pdf");
Response.Write(pdfDocument);
Response.Flush();
Response.End();
}
示例8: Write
// ---------------------------------------------------------------------------
public void Write(Stream stream) {
// step 1
using (Document document = new Document(PageSize.A5.Rotate())) {
// step 2
PdfWriter writer = PdfWriter.GetInstance(document, stream);
writer.PdfVersion = PdfWriter.VERSION_1_5;
writer.ViewerPreferences = PdfWriter.PageModeFullScreen;
writer.PageEvent = new TransitionDuration();
// step 3
document.Open();
// step 4
IEnumerable<Movie> movies = PojoFactory.GetMovies();
Image img;
PdfPCell cell;
PdfPTable table = new PdfPTable(6);
string RESOURCE = Utility.ResourcePosters;
foreach (Movie movie in movies) {
img = Image.GetInstance(Path.Combine(RESOURCE, movie.Imdb + ".jpg"));
cell = new PdfPCell(img, true);
cell.Border = PdfPCell.NO_BORDER;
table.AddCell(cell);
}
document.Add(table);
}
}
示例9: CellLayout
/**
* @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(
* com.lowagie.text.pdf.PdfPCell, com.lowagie.text.Rectangle,
* com.lowagie.text.pdf.PdfContentByte[])
*/
public void CellLayout(
PdfPCell cell, Rectangle rect, PdfContentByte[] canvas
)
{
PdfContentByte cb = canvas[PdfPTable.BACKGROUNDCANVAS];
cb.SaveState();
if (duration < 90)
{
cb.SetRGBColorFill(0x7C, 0xFC, 0x00);
}
else if (duration > 120)
{
cb.SetRGBColorFill(0x8B, 0x00, 0x00);
}
else
{
cb.SetRGBColorFill(0xFF, 0xA5, 0x00);
}
cb.Rectangle(
rect.Left, rect.Bottom,
rect.Width * duration / 240, rect.Height
);
cb.Fill();
cb.RestoreState();
}
示例10: OnEndPage
public override void OnEndPage(PdfWriter writer, Document document)
{
PdfPTable footer = new PdfPTable(3);
footer.SetWidths(new float[] { 88f, 7f, 5f });
footer.WidthPercentage = 100;
footer.TotalWidth = document.PageSize.Width - (document.LeftMargin + document.RightMargin);
PdfPCell emptycell = new PdfPCell();
emptycell.Border = 0;
footer.AddCell(emptycell);
Chunk text = new Chunk(string.Format(GlobalStringResource.PageOfFooter,
document.PageNumber), FontFactory.GetFont(FontFactory.HELVETICA, 8));
PdfPCell footerCell = new PdfPCell(new Phrase(text));
footerCell.Border = 0;
footerCell.HorizontalAlignment = Element.ALIGN_RIGHT;
footer.AddCell(footerCell);
PdfPCell cell = new PdfPCell(iTextSharp.text.Image.GetInstance(total));
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
footer.AddCell(cell);
footer.WriteSelectedRows(0, -1, 50, (document.BottomMargin - 10), writer.DirectContent);
}
示例11: CreateTable
private static PdfPTable CreateTable()
{
PdfPTable table = new PdfPTable(2);
//actual width of table in points
table.TotalWidth = 216f;
//fix the absolute width of the table
table.LockedWidth = true;
//relative col widths in proportions - 1/3 and 2/3
float[] widths = new float[] { 1f, 2f };
table.SetWidths(widths);
table.HorizontalAlignment = 0;
//leave a gap before and after the table
table.SpacingBefore = 20f;
table.SpacingAfter = 30f;
PdfPCell cell = new PdfPCell(new Phrase("Products"));
cell.Colspan = 2;
cell.Border = 0;
cell.HorizontalAlignment = 1;
table.AddCell(cell);
// Seed data:
for (int i = 0; i < DummySeed.Info.Count; i++)
{
table.AddCell(DummySeed.Info[i].Id.ToString());
table.AddCell(DummySeed.Info[i].Name);
}
return table;
}
示例12: CreateDocument
public void CreateDocument( List< ScanDetails > info, string path )
{
var doc = new Document( PageSize.A4 );
PdfWriter.GetInstance( doc, new FileStream( path, FileMode.Create ) );
doc.Open();
doc.Add( new Paragraph() );
PdfPTable table = new PdfPTable( 4 ) { WidthPercentage = 100 };
//header
PdfPCell cell = new PdfPCell { BackgroundColor = BaseColor.LIGHT_GRAY, Phrase = new Phrase( "URL" ) };
table.AddCell( cell );
cell.Phrase = new Phrase( "Response" );
table.AddCell( cell );
cell.Phrase = new Phrase( "Size" );
table.AddCell( cell );
cell.Phrase = new Phrase( "Page Title" );
table.AddCell( cell );
//rows
foreach( var item in info )
{
table.AddCell( item.Url.ToString() );
table.AddCell( item.Response );
table.AddCell( item.Size.ToString() );
table.AddCell( item.PageTitle );
}
doc.Add( table );
doc.Close();
}
示例13: MakePdfButton_Click
protected void MakePdfButton_Click(object sender, EventArgs e)
{
PdfPTable pdfTable = new PdfPTable(GridView1.HeaderRow.Cells.Count);
foreach (TableCell headeCell in GridView1.HeaderRow.Cells)
{
PdfPCell pdfPCell = new PdfPCell(new Phrase(headeCell.Text));
pdfTable.AddCell(pdfPCell);
}
foreach (GridViewRow gridViewRow in GridView1.Rows)
{
foreach (TableCell tableCell in gridViewRow.Cells)
{
PdfPCell pdfPCell = new PdfPCell(new Phrase(tableCell.Text));
pdfTable.AddCell(pdfPCell);
}
}
Document pdfDocument = new Document(PageSize.A4, 10f, 10f, 10f, 10f);
PdfWriter.GetInstance(pdfDocument, Response.OutputStream);
pdfDocument.Open();
pdfDocument.Add(pdfTable);
pdfDocument.Close();
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-disposition", "Attachment;filename=Employee.pdf");
Response.Write(pdfDocument);
Response.Flush();
Response.End();
}
示例14: btndownload_Click
protected void btndownload_Click(object sender, EventArgs e)
{
PdfPTable pdftable = new PdfPTable(gvtimetable.HeaderRow.Cells.Count);
foreach(TableCell headercell in gvtimetable.HeaderRow.Cells)
{
Font font = new Font();
font.Color = new BaseColor(gvtimetable.HeaderStyle.ForeColor);
PdfPCell pdfcell = new PdfPCell(new Phrase(headercell.Text, font));
pdfcell.BackgroundColor = new BaseColor(gvtimetable.HeaderStyle.BackColor);
pdftable.AddCell(pdfcell);
}
foreach(GridViewRow gridviewrow in gvtimetable.Rows)
{
foreach(TableCell tablecell in gridviewrow.Cells)
{
Font font = new Font();
font.Color = new BaseColor(gvtimetable.RowStyle.ForeColor);
PdfPCell pdfcell = new PdfPCell(new Phrase(tablecell.Text));
//pdfcell.BackgroundColor = ;
pdftable.AddCell(pdfcell);
}
}
Document pdfdocument = new Document(PageSize.A4, 10f, 10f, 10f, 10f);
PdfWriter.GetInstance(pdfdocument, Response.OutputStream);
pdfdocument.Open();
pdfdocument.Add(pdftable);
pdfdocument.Close();
Response.ContentType = "application/pdf";
Response.AppendHeader("content-disposition", "attachment;filename=Student_Timetable.pdf");
Response.Write(pdfdocument);
Response.Flush();
Response.End();
}
示例15: RenderHtml
/// <summary>
/// Using iTextSharp's limited HTML to PDF capabilities.
/// </summary>
public PdfPCell RenderHtml()
{
var pdfCell = new PdfPCell
{
UseAscender = true,
UseDescender = true,
VerticalAlignment = Element.ALIGN_MIDDLE
};
applyStyleSheet();
var tags = setCustomTags();
using (var reader = new StringReader(Html))
{
var parsedHtmlElements = HTMLWorker.ParseToList(reader, StyleSheet, tags, null);
foreach (var htmlElement in parsedHtmlElements)
{
applyRtlRunDirection(htmlElement);
pdfCell.AddElement(htmlElement);
}
return pdfCell;
}
}