本文整理汇总了C#中iTextSharp.text.Document.AddCreator方法的典型用法代码示例。如果您正苦于以下问题:C# Document.AddCreator方法的具体用法?C# Document.AddCreator怎么用?C# Document.AddCreator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iTextSharp.text.Document
的用法示例。
在下文中一共展示了Document.AddCreator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnCreateReport_Click
private void btnCreateReport_Click(object sender, EventArgs e)
{
// _______________________________________________________1_______________________________________________________
// Setting pagetype, margins and encryption
iTextSharp.text.Rectangle pageType = iTextSharp.text.PageSize.A4;
float marginLeft = 72;
float marginRight = 36;
float marginTop = 60;
float marginBottom = 50;
String reportName = "Test.pdf";
Document report = new Document(pageType, marginLeft, marginRight, marginTop, marginBottom);
PdfWriter writer = PdfWriter.GetInstance(report, new FileStream(reportName, FileMode.Create));
//writer.SetEncryption(PdfWriter.STRENGTH40BITS, "Good", "Bad", PdfWriter.ALLOW_COPY);
report.Open();
// _______________________________________________________2_______________________________________________________
// Setting Document properties(Meta data)
// 1. Title
// 2. Subject
// 3. Keywords
// 4. Creator
// 5. Author
// 6. Header
report.AddTitle("Employee Details Report");
report.AddSubject("This file is generated for administrative use only");
report.AddKeywords("Civil Security Department, Employee Management System, Version 1.0.0, Report Generator");
report.AddCreator("Ozious Technologies");
report.AddAuthor("Eranga Heshan");
report.AddHeader("Owner", "Civil Security Department");
// _______________________________________________________3_______________________________________________________
// Setup the font factory
/*
int totalFonts = FontFactory.RegisterDirectory("C:\\WINDOWS\\Fonts");
StringBuilder sb = new StringBuilder();
foreach (string fontname in FontFactory.RegisteredFonts) { sb.Append(fontname + "\n"); }
report.Add(new Paragraph("All Fonts:\n" + sb.ToString()));
*/
iTextSharp.text.Font fontHeader_1 = FontFactory.GetFont("Calibri", 30, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));
iTextSharp.text.Font fontHeader_2 = FontFactory.GetFont("Calibri", 15, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(125, 125, 125));
// _______________________________________________________x_______________________________________________________
// Create header
PdfContentByte cb = writer.DirectContent;
cb.MoveTo(marginLeft, marginTop);
cb.LineTo(500, marginTop);
cb.Stroke();
Paragraph paraHeader_1 = new Paragraph("Civil Security Department", fontHeader_1);
paraHeader_1.Alignment = Element.ALIGN_CENTER;
paraHeader_1.SpacingAfter = 0f;
report.Add(paraHeader_1);
Paragraph paraHeader_2 = new Paragraph("Employee Detailed Report", fontHeader_2);
paraHeader_2.Alignment = Element.ALIGN_CENTER;
paraHeader_2.SpacingAfter = 10f;
report.Add(paraHeader_2);
// _______________________________________________________x_______________________________________________________
// Adding employee image
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(imgEmployee.ImageLocation);
img.ScaleToFit(100f, 100f);
img.Border = iTextSharp.text.Rectangle.BOX;
img.BorderColor = iTextSharp.text.BaseColor.BLACK;
img.BorderWidth = 5f;
img.Alignment = iTextSharp.text.Image.TEXTWRAP | iTextSharp.text.Image.ALIGN_RIGHT | iTextSharp.text.Image.ALIGN_TOP;
img.IndentationLeft = 50f;
img.SpacingAfter = 20f;
img.SpacingBefore = 20f;
report.Add(img);
Paragraph para1 = new Paragraph("Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... ");
para1.Alignment = Element.ALIGN_JUSTIFIED;
report.Add(para1);
report.Close();
this.Close();
}
示例2: GetOrCreatePDF
/// <summary>
/// 读取或创建Pdf文档并打开写入文件流
/// </summary>
/// <param name="fileName"></param>
/// <param name="folderPath"></param>
public Document GetOrCreatePDF(string fileName, string folderPath)
{
string filePath = folderPath + fileName;
FileStream fs = null;
if (!File.Exists(filePath))
{
fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None);
}
else
{
fs = new FileStream(filePath, FileMode.Append, FileAccess.Write, FileShare.None);
}
//获取A4纸尺寸
Rectangle rec = new Rectangle(PageSize.A4);
Document doc = new Document(rec);
//创建一个 iTextSharp.text.pdf.PdfWriter 对象: 它有助于把Document书写到特定的FileStream:
PdfWriter writer = PdfWriter.GetInstance(doc, fs);
doc.AddTitle(fileName.Remove(fileName.LastIndexOf('.')));
doc.AddSubject(fileName.Remove(fileName.LastIndexOf('.')));
doc.AddKeywords("Metadata, iTextSharp 5.4.4, Chapter 1, Tutorial");
doc.AddCreator("MCS");
doc.AddAuthor("Chingy");
doc.AddHeader("Nothing", "No Header");
//打开 Document:
doc.Open();
////关闭 Document:
//doc.Close();
return doc;
}
示例3: ReportPdf
public ReportPdf(Stream Output, Layout Layout, Template Template, Dictionary<string, string> ConfigParams)
: base(Output, Layout, Template, ConfigParams)
{
Rectangle pageSize = new Rectangle(mm2pt(Template.PageSize.Width), mm2pt(Template.PageSize.Height));
// Initialization
m_Document = new Document(pageSize, mm2pt(Template.Margin.Left), mm2pt(Template.Margin.Right), mm2pt(Template.Margin.Top), mm2pt(Template.Margin.Bottom));
m_Writer = PdfWriter.GetInstance(m_Document, Output);
m_Document.AddCreationDate();
m_Document.AddCreator("StrengthReport http://dev.progterv.info/strengthreport) and KeePass (http://keepass.info)");
m_Document.AddKeywords("report");
m_Document.AddTitle(Layout.Title+" (report)");
// Header
HeaderFooter header = new HeaderFooter(new Phrase(Layout.Title+", "+DateTime.Now.ToString(), m_Template.ReportFooter.getFont()), false);
header.Alignment = Template.ReportFooter.getAlignment();
m_Document.Header = header;
// Footer
HeaderFooter footer = new HeaderFooter(new Phrase(new Chunk("Page ", m_Template.ReportFooter.getFont())), new Phrase(new Chunk(".", m_Template.ReportFooter.getFont())));
footer.Alignment = Template.ReportFooter.getAlignment();
m_Document.Footer = footer;
// TODO: Metadata
// Open document
m_Document.Open();
// Report Heading
{
PdfPTable reportTitle = new PdfPTable(1);
PdfPCell titleCell = new PdfPCell(new Phrase(Layout.Title, m_Template.ReportHeader.getFont()));
titleCell.Border = 0;
titleCell.FixedHeight = mm2pt(m_Template.ReportHeader.Height);
titleCell.VerticalAlignment = Element.ALIGN_MIDDLE;
titleCell.HorizontalAlignment = m_Template.ReportHeader.getAlignment();
reportTitle.AddCell(titleCell);
reportTitle.WidthPercentage = 100;
m_Document.Add(reportTitle);
}
// Create main table
m_Table = new PdfPTable(Layout.GetColumnWidths());
m_Table.WidthPercentage = 100;
m_Table.HeaderRows = 1;
foreach (LayoutElement element in Layout) {
PdfPCell cell = new PdfPCell(new Phrase(element.Title, m_Template.Header.getFont()));
cell.BackgroundColor = m_Template.Header.Background.ToColor();
cell.MinimumHeight = mm2pt(m_Template.Header.Height);
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
m_Table.AddCell(cell);
}
m_colorRow = new CMYKColor[] { m_Template.Row.BackgroundA.ToColor(), m_Template.Row.BackgroundB.ToColor() };
}
示例4: RenderAllTables
/// <summary>
/// Render all data add and writes it to the specified writer
/// </summary>
/// <param name="model">
/// The model to render
/// </param>
/// <param name="os">
/// The output to write to
/// </param>
public override void RenderAllTables(IDataSetModel model, Stream os)
{
// TODO check the number of horizontal & vertical key values to determine the orientation of the page
var doc = new Document(this._pageSize, 80, 50, 30, 65);
// This doesn't seem to do anything...
doc.AddHeader(Markup.HTML_ATTR_STYLESHEET, "style/pdf.css");
doc.AddCreationDate();
doc.AddCreator("NSI .NET Client");
try
{
PdfWriter.GetInstance(doc, os);
doc.Open();
this.WriteTableModels(model, doc);
}
catch (DocumentException ex)
{
Trace.Write(ex.ToString());
LogError.Instance.OnLogErrorEvent(ex.ToString());
}
catch (DbException ex)
{
Trace.Write(ex.ToString());
LogError.Instance.OnLogErrorEvent(ex.ToString());
}
finally
{
if (doc.IsOpen())
{
doc.Close();
}
}
}
示例5: CreatePdf
public void CreatePdf(Project project, Stream writeStream)
{
var document = new Document();
var writer = PdfWriter.GetInstance(document, writeStream);
// landscape
document.SetPageSize(PageSize.A4.Rotate());
document.SetMargins(36f, 36f, 36f, 36f); // 0.5 inch margins
// metadata
document.AddCreator("EstimatorX.com");
document.AddKeywords("estimation");
document.AddAuthor(project.Creator);
document.AddSubject(project.Name);
document.AddTitle(project.Name);
document.Open();
AddName(project, document);
AddDescription(project, document);
AddAssumptions(project, document);
AddFactors(project, document);
AddTasks(project, document);
AddSummary(project, document);
writer.Flush();
document.Close();
}
示例6: Build
public void Build()
{
iTextSharp.text.Document doc = null;
try
{
// Initialize the PDF document
doc = new Document();
iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(doc,
new System.IO.FileStream(System.IO.Directory.GetCurrentDirectory() + "\\ScienceReport.pdf",
System.IO.FileMode.Create));
// Set margins and page size for the document
doc.SetMargins(50, 50, 50, 50);
// There are a huge number of possible page sizes, including such sizes as
// EXECUTIVE, POSTCARD, LEDGER, LEGAL, LETTER_LANDSCAPE, and NOTE
doc.SetPageSize(new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.LETTER.Width,
iTextSharp.text.PageSize.LETTER.Height));
// Add metadata to the document. This information is visible when viewing the
// document properities within Adobe Reader.
doc.AddTitle("My Science Report");
doc.AddCreator("M. Lichtenberg");
doc.AddKeywords("paper airplanes");
// Add Xmp metadata to the document.
this.CreateXmpMetadata(writer);
// Open the document for writing content
doc.Open();
// Add pages to the document
this.AddPageWithBasicFormatting(doc);
this.AddPageWithInternalLinks(doc);
this.AddPageWithBulletList(doc);
this.AddPageWithExternalLinks(doc);
this.AddPageWithImage(doc, System.IO.Directory.GetCurrentDirectory() + "\\FinalGraph.jpg");
// Add page labels to the document
iTextSharp.text.pdf.PdfPageLabels pdfPageLabels = new iTextSharp.text.pdf.PdfPageLabels();
pdfPageLabels.AddPageLabel(1, iTextSharp.text.pdf.PdfPageLabels.EMPTY, "Basic Formatting");
pdfPageLabels.AddPageLabel(2, iTextSharp.text.pdf.PdfPageLabels.EMPTY, "Internal Links");
pdfPageLabels.AddPageLabel(3, iTextSharp.text.pdf.PdfPageLabels.EMPTY, "Bullet List");
pdfPageLabels.AddPageLabel(4, iTextSharp.text.pdf.PdfPageLabels.EMPTY, "External Links");
pdfPageLabels.AddPageLabel(5, iTextSharp.text.pdf.PdfPageLabels.EMPTY, "Image");
writer.PageLabels = pdfPageLabels;
}
catch (iTextSharp.text.DocumentException dex)
{
// Handle iTextSharp errors
}
finally
{
// Clean up
doc.Close();
doc = null;
}
}
示例7: Start
public override void Start()
{
base.Start();
this.document = (this.reportSettings.Landscape)? new Document(PageSize.A4.Rotate(),0,0,0,0) : new Document(PageSize.A4,0,0,0,0);
this.pdfUnitConverter = new PdfUnitConverter(this.document.PageSize,this.reportSettings);
this.pdfWriter = PdfWriter.GetInstance(document, new FileStream(this.fileName,FileMode.Create));
document.AddCreator(GlobalValues.ResourceString("ApplicationName"));
FontFactory.RegisterDirectories();
MyPageEvents events = new MyPageEvents();
this.pdfWriter.PageEvent = events;
}
示例8: WriteDocument
protected override void WriteDocument(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
if (File.Exists(FilePath))
throw new Pdf2KTException("File already exists.");
Document document = null;
PdfWriter writer = null;
while(Converter.MoveNext())
{
if (worker.CancellationPending == true)
{
e.Cancel = true;
break;
}
BitmapEncoder encoder = BitmapProcessor.GetBitmapEncoder();
BitmapSource processed = BitmapProcessor.Convert(Converter.Current);
if (document == null)
{
document = new Document(new Rectangle(processed.PixelWidth, processed.PixelHeight));
writer = PdfWriter.GetInstance(document, new FileStream(FilePath, FileMode.Create));
document.Open();
document.AddTitle(Converter.Document.Title);
document.AddAuthor(Converter.Document.Author);
document.AddCreationDate();
document.AddCreator("Pdf2KT");
}
document.NewPage();
using (MemoryStream ms = new MemoryStream())
{
encoder.Frames.Add(BitmapFrame.Create(processed));
encoder.Save(ms);
ms.Position = 0;
Image pdfpage = Image.GetInstance(ms);
pdfpage.SetAbsolutePosition(0, 0);
document.Add(pdfpage);
}
worker.ReportProgress((int)((Converter.CurrentProcessedPageNumber * 1f) / Converter.PageCount * 100));
}
document.Close();
}
示例9: CreateDocument
public static void CreateDocument(Stream stream, Action<Document> action)
{
using (var document = new Document(PageSize.A4))
{
var writer = PdfWriter.GetInstance(document, stream);
document.Open();
document.AddAuthor(Author);
document.AddCreator(DocumentCreator);
document.AddKeywords(DocumentKeywords);
document.AddSubject(DocumentSubject);
document.AddTitle(DocumentTitle);
action.Invoke(document);
document.Close();
}
}
示例10: CreatePdf
// ---------------------------------------------------------------------------
/**
* Creates a PDF document.
*/
public byte[] CreatePdf() {
using (MemoryStream ms = new MemoryStream()) {
// step 1
using (Document document = new Document()) {
// step 2
PdfWriter.GetInstance(document, ms);
// step 3
document.AddTitle("Hello World example");
document.AddAuthor("Bruno Lowagie");
document.AddSubject("This example shows how to add metadata");
document.AddKeywords("Metadata, iText, PDF");
document.AddCreator("My program using iText");
document.Open();
// step 4
document.Add(new Paragraph("Hello World"));
}
return ms.ToArray();
}
}
示例11: Main
private static void Main()
{
const string path = @"C:\Users\Santhosh\AppData\test.pdf";
if (File.Exists(path))
File.Delete(path);
var doc = new Document();
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(path, FileMode.Create));
// Metadata
doc.AddCreator("");
doc.AddTitle("General Receipt");
// Add content
doc.Open();
PdfContentByte cb = writer.DirectContent;
cb.SetLineWidth(0.1f);
cb.Rectangle(50f, 300f, 500f, 70f);
cb.Stroke();
doc.Close();
}
示例12: InformeEmpleado
public ActionResult InformeEmpleado(int empno)
{
EMP empleado = this.entidad.EMP.Find(empno);
Document doc = new Document(PageSize.LETTER);
//CAPTURAMOS LA RUTA AL DOCUMENTO
String ruta = HttpContext.Server.MapPath("/PDF/");
ruta = ruta + "informe" + empno.ToString() + ".pdf";
//PREGUNTAMOS SI EL DOCUMENTO EXISTE PREVIAMENTE
if (System.IO.File.Exists(ruta))
{
return File(ruta, "application/pdf");
}
else
{
//CREAMOS EL DOCUMENTO
PdfWriter writer = PdfWriter.GetInstance(doc,
new FileStream(ruta, FileMode.Create));
//INCLUIMOS TITULO Y AUTOR DEL DOCUMENTO
doc.AddTitle("Informe empleado " + empleado.APELLIDO);
doc.AddCreator("Ejemplo MVC");
//ABRIMOS EL DOCUMENTO
doc.Open();
//DEFINIMOS LA FUENTE DEL DOCUMENTO
iTextSharp.text.Font _standardFont = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 11, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
//ENCABEZADO DEL DOCUMENTO
doc.Add(new Paragraph("Informe del empleado: " + empleado.APELLIDO + ", " + DateTime.Now.ToLongDateString()));
//DAMOS UN SALTO DE LINEA
doc.Add(Chunk.NEWLINE);
//CREAMOS UNA TABLA CON LOS DATOS PARA EL EMPLEADO
//CON CUATRO DATOS A REPRESENTAR
PdfPTable tabla = new PdfPTable(4);
tabla.WidthPercentage = 100;
//CREAMOS LAS COLUMNAS CON SU TITULO Y SU VALOR
PdfPCell colapellido = new PdfPCell(new Phrase("APELLIDO", _standardFont));
colapellido.BorderWidth = 0;
colapellido.BorderWidthBottom = 0.75f;
PdfPCell coloficio = new PdfPCell(new Phrase("OFICIO", _standardFont));
coloficio.BorderWidth = 0;
coloficio.BorderWidthBottom = 0.75f;
PdfPCell colfecha = new PdfPCell(new Phrase("FECHA DE ALTA", _standardFont));
colfecha.BorderWidth = 0;
colfecha.BorderWidthBottom = 0.75f;
PdfPCell colsalario = new PdfPCell(new Phrase("SALARIO", _standardFont));
colsalario.BorderWidth = 0;
colsalario.BorderWidthBottom = 0.75f;
//AÑADIMOS LAS CELDAS A LA TABLA
tabla.AddCell(colapellido);
tabla.AddCell(coloficio);
tabla.AddCell(colfecha);
tabla.AddCell(colsalario);
//AGREGAMOS DATOS A LAS CELDAS
colapellido = new PdfPCell(new Phrase(empleado.APELLIDO, _standardFont));
colapellido.BorderWidth = 0;
coloficio = new PdfPCell(new Phrase(empleado.OFICIO, _standardFont));
coloficio.BorderWidth = 0;
colfecha = new PdfPCell(new Phrase(empleado.FECHA_ALT.ToString(), _standardFont));
colfecha.BorderWidth = 0;
colsalario = new PdfPCell(new Phrase(empleado.SALARIO.ToString() + "€", _standardFont));
colsalario.BorderWidth = 0;
//AÑADIMOS LAS CELDAS A LA TABLA
tabla.AddCell(colapellido);
tabla.AddCell(coloficio);
tabla.AddCell(colfecha);
tabla.AddCell(colsalario);
//AGREGAMOS LA TABLA AL DOCUMENTO
doc.Add(tabla);
//CERRAMOS EL DOCUMENTO
doc.Close();
writer.Close();
//DEVOLVEMOS EL DOCUMENTO CREADO
return File(ruta, "application/pdf");
}
}
示例13: CreateRem
void CreateRem()
{
string namefile = comboBox1.Text + "-Рем.pdf";
//var Документ = new iTextSharp.text.Document();
var Документ = new Document(); //создаем pdf документ iTextSharp.text.
var Писатель = PdfWriter.GetInstance(Документ, new System.IO.FileStream(namefile, System.IO.FileMode.Create)); // в текущем каталоге, если файл есть - создаст новый
Документ.SetPageSize(PageSize.A4.Rotate());
Документ.AddAuthor("Безверхий О.А.");
Документ.AddTitle("Отчёт");
Документ.AddCreator("Программа учёта ТО и Ремонта");
Документ.Open();
//Rectangle rec2 = new Rectangle(PageSize.A4);
//var БазовыйШрифт = BaseFont.CreateFont(@"C:\WINDOWS\Fonts\comic.ttf", "CP1251", BaseFont.EMBEDDED);
var БазовыйШрифт = BaseFont.CreateFont(@"C:\WINDOWS\Fonts\times.ttf", "CP1251", BaseFont.EMBEDDED);
var Шрифт = new Font(БазовыйШрифт, 12, iTextSharp.text.Font.NORMAL);
Paragraph para = new Paragraph("КАРТА УЧЕТА РЕМОНТА " + comboBox2.Text.ToUpper() + "\n", Шрифт);
para.Alignment = Element.ALIGN_CENTER;
Документ.Add(para);
para = new Paragraph(label2.Text, Шрифт);
para.Alignment = Element.ALIGN_LEFT;
Документ.Add(para);
/*para = new Paragraph("МАРКА: КЗС-1218-40 гос. № А283БВ 28rus инв. № 27" + "\n", Шрифт);
para.Alignment = Element.ALIGN_LEFT;
Документ.Add(para);
para = new Paragraph("МЕХАНИЗАТОР: Вася Петя" + "\n\n", Шрифт);
Документ.Add(para);*/
/**/
para = new Paragraph("" + "\n", Шрифт);
Документ.Add(para);
/*var Tabla = new PdfPTable(6);
Документ.Add(Tabla);*/
PdfPTable table = new PdfPTable(dataGridView1.Columns.Count);
for (int j = 0; j < dataGridView1.Columns.Count; j++)
{
table.AddCell(new Phrase(dataGridView1.Columns[j].HeaderText, Шрифт));
}
table.HeaderRows = 1;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
for (int k = 0; k < dataGridView1.Columns.Count; k++)
{
if (dataGridView1[k, i].Value != null)
{
table.AddCell(new Phrase(dataGridView1[k, i].Value.ToString(), Шрифт));
}
}
}
Документ.Add(table);
para = new Paragraph("" + "\n", Шрифт);
Документ.Add(para);
para = new Paragraph("Подпись руководителя: ", Шрифт);
para.Alignment = Element.ALIGN_LEFT;
Документ.Add(para);
//Документ.Add(new iTextSharp.text.Paragraph("Текст после таблицы", Шрифт));
Документ.Close();
Писатель.Close();
System.Diagnostics.Process.Start(namefile);
}
示例14: Ausencia
public Ausencia(AufenPortalReportesDataContext db, EMPRESA empresa, vw_Ubicacione departamento, DateTime FechaDesde, DateTime FechaHasta, string path, string rut)
{
//Nombre del archivo y ubiación en el árbol de carpetas
NombreArchivo = String.Format("{0}/{1}/PersonalAusente.pdf", empresa.Descripcion, departamento.Descripcion);
// Vamos a buscar los datos que nos permitirtán armar elreporte
IEnumerable<sp_LibroInasistenciaResult> resultado = db.sp_LibroInasistencia(
FechaDesde.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture)
, FechaHasta.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture)
, int.Parse(empresa.Codigo).ToString()
, departamento.Codigo
, rut).OrderBy(x => x.Fecha).ToList();
IEnumerable<LibroInasistenciaDTO> inasistencias =
Mapper.Map<IEnumerable<sp_LibroInasistenciaResult>, IEnumerable<LibroInasistenciaDTO>>(resultado);
if (inasistencias.Any())
{
Configuracion();
Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 50, 35);
using (var ms = new MemoryStream())
{
PdfWriter pdfWriter = PdfWriter.GetInstance(doc, ms);
pdfWriter.PageEvent = new Header(empresa, path);
doc.Open();
foreach (var reporte in inasistencias.Where(x=>x.Rut!=null).GroupBy(x => new { x.Rut, x.IdDepartamento, x.IdEmpresa }).Take(3))
{
doc.AddAuthor("Aufen");
doc.AddCreationDate();
doc.AddCreator("Aufen");
doc.AddTitle("Informe de Personal Ausente (sin marcas)");
Paragraph parrafo = new Paragraph();
parrafo.Add(new Paragraph("Informe de Personal Ausente (sin marcas)", Titulo) { Alignment = Element.ALIGN_CENTER });
parrafo.Add(new Paragraph(String.Format("Período: {0} a {1}", FechaDesde.ToShortDateString(), FechaHasta.ToShortDateString()), Normal) { Alignment = Element.ALIGN_CENTER });
parrafo.Add(new Paragraph("Centro de Costos:", Normal));
doc.Add(parrafo);
doc.Add(new Phrase());
PdfPTable tabla = new PdfPTable(new float[] {2, 2, 2, 2, 1, 1, 4 });
// Encabezado
tabla.AddCell(new PdfPCell(new Phrase("Empleado", Normal)) { Colspan = 4});
tabla.AddCell(new PdfPCell(new Phrase("Horario", Normal)) { Colspan = 2 });
tabla.AddCell(new PdfPCell(new Phrase("Autorizaciones", Normal)));
// 2 encabezado
tabla.AddCell(new PdfPCell(new Phrase("Fecha", Chico)));
tabla.AddCell(new PdfPCell(new Phrase("Rut", Chico)));
tabla.AddCell(new PdfPCell(new Phrase("Apellidos", Chico)));
tabla.AddCell(new PdfPCell(new Phrase("Nombres", Chico)));
tabla.AddCell(new PdfPCell(new Phrase("Ing.", Chico)));
tabla.AddCell(new PdfPCell(new Phrase("Sal.", Chico)));
tabla.AddCell(new PdfPCell(new Phrase("Autorizaciones", Chico)));
var empleado = db.vw_Empleados.FirstOrDefault(x => x.IdEmpresa == empresa.Codigo &&
x.IdUbicacion == reporte.Key.IdDepartamento && x.Codigo == reporte.Key.Rut);
foreach(var ausencia in reporte)
{
//Fecha
tabla.AddCell(new PdfPCell(new Phrase(ausencia.Fecha.HasValue ? ausencia.Fecha.Value.ToString("ddd dd/MM") : String.Empty, Chico)));
//Código
tabla.AddCell(new PdfPCell(new Phrase(empleado.RutAufen, Chico)));
//Apellidos
tabla.AddCell(new PdfPCell(new Phrase((ausencia.Apellidos ?? string.Empty).Trim(), Chico)));
//Nombres
tabla.AddCell(new PdfPCell(new Phrase((ausencia.Nombres ?? string.Empty).Trim(), Chico)));
//Ing.
tabla.AddCell(new PdfPCell(new Phrase(ausencia.EntradaTeorica.HasValue ? ausencia.EntradaTeorica.Value.ToString("HH:mm") : String.Empty, Chico)));
//Sal.
tabla.AddCell(new PdfPCell(new Phrase(ausencia.SalidaTeorica.HasValue ? ausencia.SalidaTeorica.Value.ToString("HH:mm") : String.Empty, Chico)));
//Autorizaciones
tabla.AddCell(new PdfPCell(new Phrase(ausencia.Observacion, Chico)));
}
doc.Add(tabla);
doc.NewPage();
}
doc.Close();
_Archivo = ms.ToArray();
}
}
}
示例15: InventarioAlmacenToolStripMenuItemClick
void InventarioAlmacenToolStripMenuItemClick(object sender, EventArgs e)
{
Document document = new Document(PageSize.LETTER);
PdfWriter.GetInstance(document, new FileStream("Administradores.pdf", FileMode.OpenOrCreate));
document.Open();
LoginMySql mostrar = new LoginMySql();
MySqlDataReader reader = mostrar.mostrarAdministradores();
document.AddAuthor("Eduardo y Oscar");
document.AddCreator("Punto de venta Carniceria");
document.Add(new Paragraph("Administradores"));
while(reader.Read())
{
string nombre = reader.GetValue(0).ToString();
string password = reader.GetValue(1).ToString();
string sueldo = reader.GetValue(2).ToString();
string direccion = reader.GetValue(3).ToString();
string telefono = reader.GetValue(4).ToString();
document.Add(new Paragraph(nombre + " - " + password + " - " + sueldo + " - " + direccion + " - " + telefono));
}
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "C:\\Users\\Cheyenne\\Desktop\\Proyecto\\puntodeventa\\bin\\Debug\\Administradores.pdf";
proc.Start();
proc.Close();
document.Close();
}