protected void Download_Click(object sender, EventArgs e) { // Check condition if (!GridView1.Columns[GridView1.Columns.Count - 1].Visible) { // Create PDF Document String Path = Server.MapPath("~\\Bangdiem\\DKHP\\DKHP_" + userName + ".pdf"); Document myDocument = new Document(PageSize.A4, 5, 5, 30, 10); if (!File.Exists(Path)) { PdfWriter.GetInstance(myDocument, new FileStream(Path, FileMode.CreateNew)); // Open document myDocument.Open(); BaseFont bf = BaseFont.CreateFont(Server.MapPath(@"~\Font\TIMES.TTF"), BaseFont.IDENTITY_H, true); iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12); iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(Server.MapPath("~/images/UIT.png")); image.Alignment = iTextSharp.text.Image.UNDERLYING; image.ScaleToFit(30f, 30f); Chunk c1 = new Chunk("TRƯỜNG ĐẠI HỌC CÔNG NGHỆ THÔNG TIN", font); c1.SetUnderline(0.5f, -4f); Paragraph Header = new Paragraph(15); Header.IndentationLeft = 15; Header.Alignment = 3; Header.Font = font; Header.Add(image); Header.SpacingBefore = 5f; Header.Add(" ĐẠI HỌC QUỐC GIA THÀNH PHỐ HỒ CHÍ MINH \n "); Header.Add(c1); Header.Add("\n\n\n"); myDocument.Add(Header); // Add gridview to iTextSharp.text.Table table = new iTextSharp.text.Table(5); // set table style properties table.BorderWidth = 1; table.BorderColor = Color.DARK_GRAY; table.Padding = 4; table.Alignment = 1; table.Width = 90; // set *column* widths float[] widths = { 0.05f, 0.23f, 0.17f, 0.45f, 0.1f }; table.Widths = widths; string[] col = { "TT", "Mã Lớp", "Mã Môn", "Tên Môn Học", "Số TC" }; font = new iTextSharp.text.Font(bf, 13, 1); // create the *table* header row for (int i = 0; i < col.Length; ++i) { Cell cell = new Cell(new Phrase(col[i], font)); cell.Header = true; cell.HorizontalAlignment = 1; table.AddCell(cell); } table.EndHeaders(); int sum = 0; font = new iTextSharp.text.Font(bf, 12); int order = 0; foreach (GridViewRow row in GridView1.Rows) { Cell c = new Cell(new Phrase((++order).ToString(), font)); c.HorizontalAlignment = 1; table.AddCell(c); c = new Cell(new Phrase(row.Cells[1].Text, font)); c.HorizontalAlignment = 1; table.AddCell(c); c = new Cell(new Phrase(((HiddenField)row.FindControl("SubID")).Value, font)); c.HorizontalAlignment = 1; table.AddCell(c); c = new Cell(new Phrase(" " + ((LinkButton)row.FindControl("SubNm")).Text, font)); table.AddCell(c); c = new Cell(new Phrase(row.Cells[3].Text, font)); c.HorizontalAlignment = 1; try { sum += Int16.Parse(row.Cells[3].Text); } catch (Exception ex) { } table.AddCell(c); } font = new iTextSharp.text.Font(bf, 14); Paragraph p = new Paragraph("ĐĂNG KÍ HỌC PHẦN HK " + getTerm() + " " + getYear() + " \n", font); p.Alignment = 1; p.Add("MSSV : " + userName); myDocument.Add(p); font = new iTextSharp.text.Font(bf, 12); c1 = new Chunk("\n\nHọ Tên : ", font); font = new iTextSharp.text.Font(bf, 12, 2); Chunk c2 = new Chunk(((Label)StudentData.Items[0].FindControl("StuNmLB")).Text, font); font = new iTextSharp.text.Font(bf, 12); Chunk c3 = new Chunk(" Khoa : ", font); font = new iTextSharp.text.Font(bf, 12, 2); Chunk c4 = new Chunk(((Label)StudentData.Items[0].FindControl("DeptLB")).Text, font); Paragraph p2 = new Paragraph(); p2.IndentationLeft = 30f; p2.Alignment = 3; p2.Add(c1); p2.Add(c2); p2.Add(c3); p2.Add(c4); myDocument.Add(p2); // Add Gridview myDocument.Add(table); if (sum > 25) { myDocument.Close(); if (File.Exists(Path)) try { File.Delete(Path); } catch (Exception ex) { } return; } font = new iTextSharp.text.Font(bf, 12); p = new Paragraph(String.Format("Tổng số TC : {0} ", sum.ToString()), font); p.Alignment = 2; myDocument.Add(p); // Add sign font = new iTextSharp.text.Font(bf, 13); p = new Paragraph("\n\n\n Chữ ký SV", font); p.Add(" Chữ ký PĐT\n\n"); p.Add(" ......................."); p.Add(" ........................\n"); myDocument.Add(p); // Check List<string> DateL = new List<string>(); List<string> Derror = new List<string>(); String error = ""; bool first = true; foreach (GridViewRow grow in GridView1.Rows) { string Date = ((Label)grow.FindControl("Day")).Text; string Period = ((Label)grow.FindControl("Period")).Text; string[] dates = Date.Replace("<br/>", ",").Split(','); string[] periods = Period.Replace("<br/>", ",").Split(','); for (int i = 0; i < dates.Length; i++) { string dateandperiod = dates[i] + periods[i]; if (DateL.Contains(dateandperiod)) // Error on samq datetime { if (!Derror.Contains(dateandperiod)) { if (first) { error += "Thứ " + dates[i] + " ca " + periods[i]; first = false; } else error += ", Thứ " + dates[i] + " ca " + periods[i]; Derror.Add(dateandperiod); } } else DateL.Add(dateandperiod); } } if (error != "") { font = new iTextSharp.text.Font(bf, 12); p = new Paragraph("\n\n Ghi chú : trùng giờ học ", font); p.Add("\n (" + error + ")"); myDocument.Add(p); } font = new iTextSharp.text.Font(bf, 11); p = new Paragraph("\n In vào :" + DateTime.UtcNow.ToShortTimeString() + " " + DateTime.UtcNow.ToShortDateString(), font); p.Add("\n Chú ý : Sinh viên \n không được tự ý thay đổi nội dung file này."); myDocument.Add(p); // Close document myDocument.Close(); // Check connection and trangfer file using (SqlConnection scon = new SqlConnection(ConnectionString)) { scon.Open(); using (SqlCommand scom = new SqlCommand("Insert into DownloadLog values(@StuID,getdate())", scon)) { scom.Parameters.Add("@StuID", userName); try { scom.ExecuteNonQuery(); } catch (Exception ex) { using (SqlCommand scom1 = new SqlCommand("Update Downloadlog set log = getdate() where StuID = @StuID", scon)) { try { scom1.Parameters.Add("@StuID", userName); scom1.ExecuteNonQuery(); } catch (Exception ex1) { } } } } } } Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/pdf"; Response.AddHeader ("Content-Disposition", "attachment; filename = DKHP_" + userName + ".pdf"); Response.TransmitFile(Path); Response.End(); Response.Flush(); Response.Clear(); } }
private Table GeneratePDFTable(IList <ProductListView> list, string[] titles, string[] columns) { Table datatable = new Table(columns.Length); datatable.Padding = 2; datatable.Spacing = 0; float[] headerwidths; if (!CanExportAll) { headerwidths = new float[] { 85, 450, 65, 120 } } ; else { headerwidths = new float[] { 85, 200, 110, 90, 120, 60, 120, 65, 65, 65, 65, 65, 65, 65, 65, 100 } }; datatable.Widths = headerwidths; datatable.WidthPercentage = 100; datatable.DefaultCellBorderWidth = 1; datatable.BackgroundColor = Color.LIGHT_GRAY; Font myfont = new Font(FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, iTextSharp.text.Font.NORMAL)); Font myfontTitle = new Font(FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, iTextSharp.text.Font.BOLD, new Color(255, 255, 255))); Cell cel = new Cell(); foreach (string title in titles) { cel = new Cell(); cel.Add(new Phrase(title, myfontTitle)); cel.BackgroundColor = new Color(0, 51, 102); cel.HorizontalAlignment = Element.ALIGN_CENTER; datatable.AddCell(cel); } datatable.EndHeaders(); datatable.BackgroundColor = Color.WHITE; foreach (object r in list) { foreach (string column in columns) { object o = r.GetType().GetProperty(column).GetValue(r, new object[0]); string val; if (o is double || o is decimal) { val = Convert.ToDouble(o).ToString("0.00"); } else { val = Convert.ToString(o); } cel = new Cell(); cel.Add(new Phrase(val, myfont)); cel.SetHorizontalAlignment(ElementTags.LEFT); if (column != "FinalInfo" && column != "Provider") { cel.HorizontalAlignment = Element.ALIGN_RIGHT; } datatable.AddCell(cel); } } return(datatable); }
protected static DocumentPDF printTable(StampaVO.Table tableTmp, DataTable dt, DocumentPDF docPDF) { if (dt == null) { return(docPDF); } //** Operazioni Preliminari //reupero del numero di colonne dal DataTable int col = tableTmp.columns.Length; int col_visible = 0; for (int j = 0; j < tableTmp.columns.Length; j++) { if (tableTmp.columns[j].visible) { col_visible++; } } try { //creazione della tabella iTextSharp.text.Table aTable = new iTextSharp.text.Table(col_visible); //Adattamento delle colonne al contenuto aTable.Padding = tableTmp.padding; aTable.Spacing = tableTmp.spacing; aTable.Width = 100; aTable.Alignment = Utils.getAlign(tableTmp.align); int[] widths = getColWidths(tableTmp, col_visible); aTable.SetWidths(widths); aTable.TableFitsPage = true; //** Aggiunta automatica dell'header della tabella for (int k = 0; k < col; k++) { if (((StampaVO.Column)tableTmp.columns[k]).visible) { StampaVO.Font font = tableTmp.headerTable.font; Font font1 = FontFactory.GetFont(font.name, font.size, Utils.getFontStyle(font.style), Utils.getColor(font.color)); string testo = ((StampaVO.Column)tableTmp.columns[k]).alias; Cell c = new Cell(new Phrase(testo, font1)); c.HorizontalAlignment = Utils.getAlign(tableTmp.headerTable.align); c.VerticalAlignment = Utils.getAlign(tableTmp.headerTable.vAlign); //c.NoWrap=true; c.BackgroundColor = Utils.getColor(tableTmp.headerTable.bgColor); aTable.AddCell(c); } } aTable.EndHeaders(); //** Popolamento automatico della tabella //Scansione dei dati for (int i = 0; i < dt.Rows.Count; i++) { //Creazione delle celle for (int h = 0; h < col; h++) { if (((StampaVO.Column)tableTmp.columns[h]).visible) { StampaVO.Font font = tableTmp.dataTable.font; Font font1 = FontFactory.GetFont(font.name, font.size, Utils.getFontStyle(font.style), Utils.getColor(font.color)); string column_name = tableTmp.columns[h].name; Cell c1 = new Cell(new Phrase(dt.Rows[i][column_name].ToString(), font1)); c1.HorizontalAlignment = Utils.getAlign(tableTmp.columns[h].align); c1.VerticalAlignment = Utils.getAlign(tableTmp.columns[h].vAlign); if (!string.IsNullOrEmpty(tableTmp.columns[h].bgColor)) { c1.BackgroundColor = Utils.getColor(tableTmp.columns[h].bgColor); } aTable.AddCell(c1, new System.Drawing.Point(i + 1, h)); } } } docPDF.Add(aTable); } catch (Exception ex) { docPDF.Close(); writer.Close(); throw new ReportException(ErrorCode.IncompletePDFFile, "Errore nella scrittura dei dati: " + ex.Message); } return(docPDF); }
protected void GeneratePDF() { // Refresh the grid else there will be nothing to generate (no postback) this.PopulateGrid(); // Create and initialize a new document object iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.LEGAL, 24, 24, 24, 24); document.PageSize.Rotate(); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); try { // Create an instance of the writer object iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, memoryStream); // Add some meta information to the document Label lblPageTitle = (Label)(this.Page.Master.FindControl("lblDefaultMasterPageTitle")); document.AddAuthor(lblPageTitle.Text); document.AddSubject(this.lblReportTitle.Text); // Open the document document.Open(); // Create a table to match our current summary grid iTextSharp.text.Table table = new iTextSharp.text.Table(4); table.TableFitsPage = true; // Apply spacing/padding/borders/column widths to the table table.Padding = 2; table.Spacing = 0; table.DefaultCellBorderWidth = 1; float[] headerwidths = { 40, 30, 30, 35 }; table.Widths = headerwidths; table.Width = 100; // Add report title spanning all columns iTextSharp.text.Font titleFont = new iTextSharp.text.Font(Font.GetFamilyIndex("Tahoma"), 4, Font.BOLD); titleFont.Color = new iTextSharp.text.Color(System.Drawing.Color.Firebrick); iTextSharp.text.Cell titleCell = new iTextSharp.text.Cell(); titleCell.SetHorizontalAlignment("Left"); titleCell.SetVerticalAlignment("Top"); titleCell.BackgroundColor = new iTextSharp.text.Color(System.Drawing.Color.White); titleCell.BorderWidth = 0; titleCell.Colspan = 4; titleCell.AddElement(new iTextSharp.text.Phrase(this.lblReportTitle.Text, titleFont)); table.AddCell(titleCell); // Add table headers for (int i = 0; i < this.grdReporting.Columns.Count; i++) { iTextSharp.text.Font headerCellFont = new iTextSharp.text.Font(Font.GetFamilyIndex("Tahoma"), 8, Font.NORMAL + Font.UNDERLINE); headerCellFont.Color = new iTextSharp.text.Color(System.Drawing.Color.White); iTextSharp.text.Cell headerCell = new iTextSharp.text.Cell(); headerCell.SetHorizontalAlignment("Left"); headerCell.SetVerticalAlignment("Top"); headerCell.BackgroundColor = new iTextSharp.text.Color(System.Drawing.Color.SteelBlue); headerCell.BorderColor = new iTextSharp.text.Color(System.Drawing.Color.White); headerCell.AddElement(new iTextSharp.text.Phrase(this.grdReporting.Columns[i].HeaderText, headerCellFont)); table.AddCell(headerCell); } table.EndHeaders(); // Add data to the table int j = 0; int k = 0; string phrase = ""; foreach (System.Data.DataRow row in this._pdfDataTable.Rows) { j++; // Increment the row counter k = 0; // Reset the column counter for the new row foreach (System.Data.DataColumn col in this._pdfDataTable.Columns) { k++; // Increment the column counter iTextSharp.text.Font cellFont = new iTextSharp.text.Font(Font.GetFamilyIndex("Tahoma"), 7, Font.NORMAL); if (j % 2 == 0) { cellFont.Color = new iTextSharp.text.Color(System.Drawing.Color.DarkRed); } else { cellFont.Color = new iTextSharp.text.Color(System.Drawing.Color.Black); } iTextSharp.text.Cell cell = new iTextSharp.text.Cell(); cell.SetHorizontalAlignment("Left"); cell.SetVerticalAlignment("Top"); cell.BorderColor = new iTextSharp.text.Color(System.Drawing.Color.White); if (j % 2 == 0) { cell.BackgroundColor = new iTextSharp.text.Color(System.Drawing.Color.LightGray); } else { cell.BackgroundColor = new iTextSharp.text.Color(System.Drawing.Color.White); } // Generate formatted phrase for cell. switch (col.ColumnName) { case "TotalCount": phrase = String.Format("{0:G}", row[col]); break; case "AvgSecs": case "StdDevSecs": phrase = String.Format("{0:F2}", row[col]); break; default: phrase = row[col].ToString(); break; } cell.AddElement(new iTextSharp.text.Phrase(phrase, cellFont)); table.AddCell(cell); } } // Add the table to the document document.Add(table); // Close the document document.Close(); // Show the document Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=MonthlyReportingPerformance.pdf"); Response.ContentType = "application/pdf"; Response.BinaryWrite(memoryStream.ToArray()); Response.End(); } catch (Exception xcptn) { Response.Write(xcptn.Message); } }
private Table GeneratePDFTable(IList <ProductListView> list, string[] titles, string[] columns) { Table datatable = new Table(columns.Length); datatable.Padding = 2; datatable.Spacing = 0; float[] headerwidths; headerwidths = new float[] { 85, 500, 45, 90 }; datatable.Widths = headerwidths; datatable.WidthPercentage = 100; datatable.DefaultCellBorderWidth = 1; datatable.BackgroundColor = Color.LIGHT_GRAY; Font myfont = new Font(FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.NORMAL)); Font myfontTitle = new Font(FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.BOLD)); Cell cel = new Cell(); foreach (string title in titles) { cel = new Cell(); cel.Add(new Phrase(title, myfontTitle)); cel.BackgroundColor = Color.LIGHT_GRAY; cel.HorizontalAlignment = Element.ALIGN_CENTER; datatable.AddCell(cel); } datatable.EndHeaders(); datatable.BackgroundColor = Color.WHITE; foreach (object r in list) { foreach (string column in columns) { object o = r.GetType().GetProperty(column).GetValue(r, new object[0]); string val; if (o is double || o is decimal) { val = Convert.ToDouble(o).ToString("0.00"); } else { val = Convert.ToString(o); } cel = new Cell(); cel.Add(new Phrase(val, myfont)); cel.HorizontalAlignment = Element.ALIGN_LEFT; if (column != "Description") { cel.HorizontalAlignment = Element.ALIGN_RIGHT; } datatable.AddCell(cel); } } return(datatable); }
/// <summary> /// overloading per passare nome e cognome dell'utente loggato,in modo da evidenziare le trasmissioni di cui l'utente è destinatario /// Dimitri /// </summary> /// <param name="tableTmp"></param> /// <param name="dt"></param> /// <param name="docPDF"></param> /// <param name="infoUt"></param> /// <returns></returns> protected static DocumentPDF printCustomTable(StampaVO.Table tableTmp, DataTable dt, DocumentPDF docPDF, DocsPaVO.utente.InfoUtente infoUt) { if (dt == null) { return(docPDF); } //** Operazioni Preliminari //reupero del numero di colonne dal DataTable int col = tableTmp.columns.Length; int col_visible = 0; for (int j = 0; j < tableTmp.columns.Length; j++) { if (tableTmp.columns[j].visible) { col_visible++; } } try { //creazione della tabella iTextSharp.text.Table aTable = new iTextSharp.text.Table(col_visible); //Adattamento delle colonne al contenuto aTable.Padding = tableTmp.padding; aTable.Spacing = tableTmp.spacing; //aTable.WidthPercentage = 100; aTable.Width = 100; aTable.Alignment = Utils.getAlign(tableTmp.align); int[] widths = getColWidths(tableTmp, col_visible); aTable.SetWidths(widths); //aTable.hasToFitPageCells(); aTable.TableFitsPage = true; //** Aggiunta automatica dell'header della tabella for (int k = 0; k < col; k++) { if (((StampaVO.Column)tableTmp.columns[k]).visible) { StampaVO.Font font = tableTmp.headerTable.font; Font font1 = FontFactory.GetFont(font.name, font.size, Utils.getFontStyle(font.style), Utils.getColor(font.color)); string testo = ((StampaVO.Column)tableTmp.columns[k]).alias; string[] testoSplit = testo.Split(';'); string testo_1 = string.Empty; if (testoSplit.Length > 1) { testo_1 = @testoSplit[0] + "\n" + testoSplit[1]; } else { testo_1 = testoSplit[0]; } Cell c = new Cell(new Phrase(testo_1, font1)); if (((StampaVO.Column)tableTmp.columns[k]).name == "DESCR" || ((StampaVO.Column)tableTmp.columns[k]).name == "MITT_UT" || ((StampaVO.Column)tableTmp.columns[k]).name == "DEST" || ((StampaVO.Column)tableTmp.columns[k]).name == "NOTE_GENER") { c.HorizontalAlignment = Utils.getAlign("LEFT"); } else { c.HorizontalAlignment = Utils.getAlign(tableTmp.headerTable.align); } c.VerticalAlignment = Utils.getAlign(tableTmp.headerTable.vAlign); c.NoWrap = true; c.BackgroundColor = Utils.getColor(tableTmp.headerTable.bgColor); aTable.AddCell(c); } } aTable.EndHeaders(); //** Popolamento automatico della tabella //Scansione dei dati for (int i = 0; i < dt.Rows.Count; i++) { //Creazione delle celle for (int h = 0; h < col; h++) { if (((StampaVO.Column)tableTmp.columns[h]).visible) { StampaVO.Font font = tableTmp.dataTable.font; string style = font.style; string column_name = tableTmp.columns[h].name; string evidenziaDest = ""; if (dt.Rows[i]["SYSTEM_ID_DEST_UT"].ToString() == infoUt.idPeople && column_name == "DEST_UT") { evidenziaDest = " *"; style = "BOLD"; } Font font1 = FontFactory.GetFont(font.name, font.size, Utils.getFontStyle(style), Utils.getColor(font.color)); // Font font1 = FontFactory.GetFont(font.name, font.size, Utils.getFontStyle(font.style), Utils.getColor(font.color)); Cell c1; if (column_name == "ID_REG_PROTO_ANNO") { string s = string.Empty; if (dt.Rows[i]["COD_REG"].ToString() != "") { s = @dt.Rows[i]["ID"].ToString() + "\n" + dt.Rows[i]["COD_REG"].ToString() + " - " + dt.Rows[i]["NUM_PROTO"].ToString() + " - " + dt.Rows[i]["ANNO"].ToString(); } else { s = dt.Rows[i]["ID"].ToString() + "\n Non Protocollato"; } c1 = new Cell(new Phrase(s, font1)); c1.HorizontalAlignment = Utils.getAlign(tableTmp.columns[h].align); c1.VerticalAlignment = Utils.getAlign(tableTmp.columns[h].vAlign); aTable.AddCell(c1, new System.Drawing.Point(i + 1, h)); } if (column_name == "MITT_UT") { string s = @dt.Rows[i][column_name].ToString(); c1 = new Cell(new Phrase(s, font1)); c1.HorizontalAlignment = Utils.getAlign(tableTmp.columns[h].align); c1.VerticalAlignment = Utils.getAlign(tableTmp.columns[h].vAlign); aTable.AddCell(c1, new System.Drawing.Point(i + 1, h)); } if (column_name == "MITT_RU") { string s = dt.Rows[i]["MITT_RU"].ToString(); c1 = new Cell(new Phrase(s, font1)); c1.HorizontalAlignment = Utils.getAlign(tableTmp.columns[h].align); c1.VerticalAlignment = Utils.getAlign(tableTmp.columns[h].vAlign); aTable.AddCell(c1, new System.Drawing.Point(i + 1, h)); } //Aggiunta note individuali alle generali if (column_name == "NOTE_GENER") { if (dt.Rows[i]["NOTE_INDIVID"] != null) { string s = @dt.Rows[i]["NOTE_GENER"].ToString() + Environment.NewLine + "--------------" + Environment.NewLine; if (dt.Rows[i]["SYSTEM_ID_MITT_UT"].ToString() == infoUt.idPeople) { s += dt.Rows[i]["NOTE_INDIVID"].ToString(); } c1 = new Cell(new Phrase(s, font1)); c1.HorizontalAlignment = Utils.getAlign(tableTmp.columns[h].align); c1.VerticalAlignment = Utils.getAlign(tableTmp.columns[h].vAlign); aTable.AddCell(c1, new System.Drawing.Point(i + 1, h)); } } if (column_name == "DEST_UT") { if (dt.Rows[i]["DEST_UT"] != null) { string s = @dt.Rows[i]["DEST_UT"].ToString() + evidenziaDest; c1 = new Cell(new Phrase(s, font1)); c1.HorizontalAlignment = Utils.getAlign(tableTmp.columns[h].align); c1.VerticalAlignment = Utils.getAlign(tableTmp.columns[h].vAlign); aTable.AddCell(c1, new System.Drawing.Point(i + 1, h)); } } if (column_name != "ID_REG_PROTO_ANNO" && column_name != "MITT_UT" && column_name != "MITT_RU" && column_name != "NUM_PROTO" && column_name != "ANNO" && column_name != "NOTE_GENER" && column_name != "DEST_UT") { c1 = new Cell(new Phrase(dt.Rows[i][column_name].ToString(), font1)); c1.HorizontalAlignment = Utils.getAlign(tableTmp.columns[h].align); c1.VerticalAlignment = Utils.getAlign(tableTmp.columns[h].vAlign); aTable.AddCell(c1, new System.Drawing.Point(i + 1, h)); } } } } // aTable.Complete(); // aTable.FlushContent(); docPDF.Add(aTable); } catch (Exception ex) { docPDF.Close(); writer.Close(); throw new ReportException(ErrorCode.IncompletePDFFile, "Errore nella scrittura dei dati: " + ex.Message); } return(docPDF); }
public void GenerateXMLReport() { try { this.doc.Open(); RenderLogo(); RenderDescription(); RenderReportJobInfo(); iTextSharp.text.Table myTable = new iTextSharp.text.Table(ColList.Count); myTable.Widths = this.Headerwidths; myTable.WidthPercentage = 100; //myTable.Locked = true; //Render Table Headers~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ myTable.DefaultLayout.HorizontalAlignment = Element.ALIGN_LEFT; myTable.DefaultCell.BorderWidth = ReportBorderWidth; myTable.Cellpadding = 1; myTable.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE; myTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; myTable.DefaultCell.BackgroundColor = Color.LIGHT_GRAY; myTable.DefaultCell.UseBorderPadding = true; foreach (var x in this.ColList) { myTable.AddCell(new Phrase(x, fntHeading)); } myTable.EndHeaders(); //Render Details~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Font myDetailFont = fntDetails; foreach (var x in this.ReportRows) { for (int i = 0; i < ColList.Count; i++) { myTable.DefaultCell.BackgroundColor = Color.WHITE; if (x.row[i].type == CellType.Number) myTable.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT; else myTable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; if (i > ColList.Count - 3) myTable.DefaultCell.BackgroundColor = Color.LIGHT_GRAY; else myTable.DefaultCell.BackgroundColor = Color.WHITE; if (i == ColList.Count - 3) myTable.AddCell(new Phrase(x.row[i].value, footerFont)); else myTable.AddCell(new Phrase(x.row[i].value, myDetailFont)); } } //Footer Totals~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ myTable.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT; myTable.DefaultCell.BackgroundColor = Color.WHITE; myTable.DefaultCell.Colspan = 4; myTable.AddCell(new Phrase("Totals", footerFont)); myTable.DefaultCell.Colspan = 1; for (int i = 4; i < FooterList.Count; i++) { myTable.AddCell(new Phrase(FooterList[i], footerFont)); //if ((FooterList[i].Length > 0 && SacoList[i].Length > 0) && (decimal.Parse(FooterList[i]) > decimal.Parse(SacoList[i]))) //{ // myTable.AddCell(new Phrase(FooterList[i], ErrorFont)); //} //else //{ // if (SacoList[i].Trim().Length == 0) // myTable.AddCell(new Phrase(FooterList[i], ErrorFont)); // else // myTable.AddCell(new Phrase(FooterList[i], footerFont)); //} } //Render Saco Totals~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ myTable.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT; myTable.DefaultCell.BackgroundColor = Color.BLUE; myTable.DefaultCell.Colspan = 4; myTable.AddCell(new Phrase("Saco Hours", SacoFont)); myTable.DefaultCell.Colspan = 1; for (int i = 4; i < SacoList.Count; i++) { myTable.AddCell(new Phrase(SacoList[i], SacoFont)); } //Render Diff Totals~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ myTable.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT; myTable.DefaultCell.BackgroundColor = Color.WHITE; myTable.DefaultCell.Colspan = 4; myTable.AddCell(new Phrase("Diff", footerFont)); myTable.DefaultCell.Colspan = 1; decimal diff = 0M; string cellvalue = ""; decimal sacovalue = 0M; decimal footervalue = 0M; for (int i = 4; i < SacoList.Count; i++) { diff = 0M; sacovalue = (SacoList[i].Length > 0)? decimal.Parse(SacoList[i]) : 0M; footervalue = (FooterList[i].Length >0) ? decimal.Parse(FooterList[i]) : 0M; diff = sacovalue - footervalue; cellvalue = (diff == 0) ? string.Empty : diff.ToString("#0.00"); myTable.AddCell(new Phrase(cellvalue, footerFont)); } //Put in a blank line~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //myTable.DefaultCell.BorderWidth = 0; //myTable.DefaultCell.BackgroundColor = Color.WHITE; //for (int row = 0; row < 10; row++) //{ // for (int i = 0; i < this.SacoList.Count; i++) // { // myTable.AddCell(new Phrase(" ", fntDetails)); // } //} doc.Add(myTable); //Render Signature Section~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //RenderSignatueSection(); #endregion } catch (Exception ex) { throw (new Exception("Error: " + ex.Message)); } doc.Close(); writer.Close(); }
private void EscrevaProcessosNoDocumentoAnalitico() { var tabela = new Table(6); tabela.Widths = new Single[] { 60, 100, 50, 100, 60, 100 }; tabela.Padding = 0; tabela.Spacing = 0; tabela.Width = 100; tabela.AutoFillEmptyCells = true; tabela.EndHeaders(); foreach (var processo in _processos) { var labelNumeroProcesso = new Cell(new Phrase("Número do processo: ", _Fonte2)); labelNumeroProcesso.DisableBorderSide(0); tabela.AddCell(labelNumeroProcesso); var valorNumeroProcesso = new Cell(new Phrase(processo.Processo.ToString(), _Fonte1)); valorNumeroProcesso.DisableBorderSide(0); tabela.AddCell(valorNumeroProcesso); var labelDataDoCadastro = new Cell(new Phrase("Data do cadastro: ", _Fonte2)); labelDataDoCadastro.DisableBorderSide(0); tabela.AddCell(labelDataDoCadastro); var valorDataDoCadastro = new Cell(new Phrase(processo.DataDoCadastro.ToString("dd/MM/yyyy"), _Fonte1)); valorDataDoCadastro.DisableBorderSide(0); tabela.AddCell(valorDataDoCadastro); var labelDespacho = new Cell(new Phrase("Despacho: ", _Fonte2)); labelDespacho.DisableBorderSide(0); tabela.AddCell(labelDespacho); var valorDespacho = processo.Despacho != null ? new Cell(new Phrase(processo.Despacho.CodigoDespacho, _Fonte1)) : new Cell(new Phrase(string.Empty, _Fonte1)); valorDespacho.DisableBorderSide(0); tabela.AddCell(valorDespacho); var labelApresentacao = new Cell(new Phrase("Apresentação: ", _Fonte2)); labelApresentacao.DisableBorderSide(0); tabela.AddCell(labelApresentacao); Cell valorApresentacao; if(processo.Marca != null && processo.Marca.Apresentacao != null) valorApresentacao = new Cell(new Phrase(processo.Marca.Apresentacao.Nome, _Fonte1)); else valorApresentacao = new Cell(new Phrase(string.Empty, _Fonte1)); valorApresentacao.DisableBorderSide(0); tabela.AddCell(valorApresentacao); var labelNatureza = new Cell(new Phrase("Natureza: ", _Fonte2)); labelNatureza.DisableBorderSide(0); tabela.AddCell(labelNatureza); Cell valorNatureza; if (processo.Marca != null && processo.Marca.Natureza != null) valorNatureza = new Cell(new Phrase(processo.Marca.Natureza.Nome, _Fonte1)); else valorNatureza = new Cell(new Phrase(string.Empty, _Fonte1)); valorNatureza.DisableBorderSide(0); tabela.AddCell(valorNatureza); var labelNCL = new Cell(new Phrase("NCL: ", _Fonte2)); labelNCL.DisableBorderSide(0); tabela.AddCell(labelNCL); Cell valorNCL; if (processo.Marca != null && processo.Marca.NCL != null) valorNCL = new Cell(new Phrase(processo.Marca.NCL.Codigo, _Fonte1)); else valorNCL = new Cell(new Phrase(string.Empty, _Fonte1)); valorNCL.DisableBorderSide(0); tabela.AddCell(valorNCL); var labelCliente = new Cell(new Phrase("Cliente: ", _Fonte2)); labelCliente.DisableBorderSide(0); tabela.AddCell(labelCliente); var valorCliente = new Cell(new Phrase(processo.Marca.Cliente.Pessoa.Nome, _Fonte1)) { Colspan = 5 }; valorCliente.DisableBorderSide(0); tabela.AddCell(valorCliente); var labelMarca = new Cell(new Phrase("Marca: ", _Fonte2)); labelMarca.DisableBorderSide(0); tabela.AddCell(labelMarca); Cell valorMarca; if (processo.Marca != null && !string.IsNullOrEmpty(processo.Marca.DescricaoDaMarca)) valorMarca = new Cell(new Phrase(processo.Marca.DescricaoDaMarca, _Fonte1)); else valorMarca = new Cell(new Phrase(string.Empty, _Fonte1)); valorMarca.Colspan = 5; valorMarca.DisableBorderSide(0); tabela.AddCell(valorMarca); var labelApostila = new Cell(new Phrase("Apostila: ", _Fonte2)); labelApostila.DisableBorderSide(0); tabela.AddCell(labelApostila); Cell valorApostila; if (!string.IsNullOrEmpty(processo.Apostila)) valorApostila = new Cell(new Phrase(processo.Apostila, _Fonte1)); else valorApostila = new Cell(new Phrase(string.Empty, _Fonte1)); valorApostila.Colspan = 5; valorApostila.DisableBorderSide(0); tabela.AddCell(valorApostila); var labelTextoDespacho = new Cell(new Phrase("Texto do Despacho: ", _Fonte2)); labelTextoDespacho.DisableBorderSide(0); tabela.AddCell(labelTextoDespacho); Cell valorTextoDespacho; if (!string.IsNullOrEmpty(processo.TextoComplementarDoDespacho)) valorTextoDespacho = new Cell(new Phrase(processo.Apostila, _Fonte1)); else valorTextoDespacho = new Cell(new Phrase(string.Empty, _Fonte1)); valorTextoDespacho.Colspan = 5; valorTextoDespacho.DisableBorderSide(0); tabela.AddCell(valorTextoDespacho); var labelProcurador = new Cell(new Phrase("Procurador: ", _Fonte2)); labelProcurador.DisableBorderSide(0); tabela.AddCell(labelProcurador); Cell valorProcurador; if (processo.Procurador != null && processo.Procurador.Pessoa != null && !string.IsNullOrEmpty(processo.Procurador.Pessoa.Nome)) valorProcurador = new Cell(new Phrase(processo.Procurador.Pessoa.Nome, _Fonte1)); else valorProcurador = new Cell(new Phrase(string.Empty, _Fonte1)); valorProcurador.Colspan = 5; valorProcurador.DisableBorderSide(0); tabela.AddCell(valorProcurador); var linhaVazia = new Cell(new Phrase("\n", _Fonte1)); linhaVazia.Colspan = 6; linhaVazia.DisableBorderSide(1); tabela.AddCell(linhaVazia); } _documento.Add(tabela); }
private void EscrevaProcessosNoDocumentoAnalitico() { var tabela = new Table(1); tabela.Widths = new Single[] { 218 }; tabela.Padding = 0; tabela.Spacing = 0; tabela.Width = 100; tabela.AutoFillEmptyCells = true; tabela.DefaultCell.Border = Rectangle.NO_BORDER; tabela.EndHeaders(); foreach (var revistaDePatente in _revistasPatentes) { var tabela1 = new Table(1); tabela1.Widths = new Single[] { 100 }; tabela1.Padding = 0; tabela1.Spacing = 0; tabela1.Width = 100; tabela1.AutoFillEmptyCells = true; tabela1.Border = 0; tabela1.EndHeaders(); tabela1.DefaultCell.Border = Rectangle.NO_BORDER; var tabelaProcesso = new Cell(ObtenhaTabelaCelulaProcesso(revistaDePatente)); tabela1.AddCell(tabelaProcesso); var tabelaRevistas = new Cell(ObtenhaTabelaInformacoesRevista(revistaDePatente)); tabela1.AddCell(tabelaRevistas); tabela.AddCell(new Cell(tabela1)); tabela.AddCell(ObtenhaCelulaVazia()); tabela.AddCell(ObtenhaCelulaVazia()); tabela.AddCell(ObtenhaCelulaVazia()); } _documento.Add(tabela); }
private void EscrevaProcessosNoDocumento() { Table tabela = new Table(9); tabela.Widths = new Single[] {100, 100, 100, 100, 100, 400, 400, 90, 85}; tabela.Padding = 1; tabela.Spacing = 0; tabela.Width = 100; tabela.AutoFillEmptyCells = true; var corBackgroudHeader = new Color(211, 211, 211); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Número do processo", _Fonte2, Cell.ALIGN_CENTER, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Data do cadastro", _Fonte2, Cell.ALIGN_CENTER, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Data do depósito", _Fonte2, Cell.ALIGN_CENTER, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Data de concessão", _Fonte2, Cell.ALIGN_CENTER, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Data da vigência", _Fonte2, Cell.ALIGN_CENTER, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Marca", _Fonte2, Cell.ALIGN_LEFT, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Cliente", _Fonte2, Cell.ALIGN_LEFT, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Despacho", _Fonte2, Cell.ALIGN_CENTER, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Ativo?", _Fonte2, Cell.ALIGN_CENTER, 0, corBackgroudHeader, true)); tabela.EndHeaders(); foreach (var processo in _processos) { tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.Processo.ToString(), _Fonte1, Cell.ALIGN_CENTER,0, false)); tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.DataDoCadastro.ToString("dd/MM/yyyy"), _Fonte1, Cell.ALIGN_CENTER, 0, false)); tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.DataDoDeposito.HasValue ? processo.DataDoDeposito.Value.ToString("dd/MM/yyyy") : "", _Fonte1, Cell.ALIGN_CENTER, 0, false)); tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.DataDeConcessao.HasValue ? processo.DataDeConcessao.Value.ToString("dd/MM/yyyy") : "", _Fonte1, Cell.ALIGN_CENTER, 0, false)); tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.DataDaVigencia.HasValue ? processo.DataDaVigencia.Value.ToString("dd/MM/yyyy") : "", _Fonte1, Cell.ALIGN_CENTER, 0, false)); tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.Marca.DescricaoDaMarca, _Fonte1, Cell.ALIGN_LEFT,0 , false)); tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.Marca.Cliente.Pessoa.Nome, _Fonte1, Cell.ALIGN_LEFT, 0, false)); tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.Despacho != null ? processo.Despacho.CodigoDespacho.ToString() : "", _Fonte1, Cell.ALIGN_CENTER, 0, false)); tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.Ativo ? "SIM" : "NÃO", _Fonte1, Cell.ALIGN_CENTER, 0, false)); } _documento.Add(tabela); // Chunk linhaQuantidadeDeItens = new Chunk(String.Concat("Quantidade de processos de marcas : ", _processos.Count), _Fonte4); // _documento.Add(linhaQuantidadeDeItens); }
private Table ObtenhaTabelaInformacoesRevista(IRevistaDePatente revista) { var tabela = new Table(1); tabela.Widths = new Single[] { 100 }; tabela.Padding = 0; tabela.Spacing = 0; tabela.Width = 100; tabela.AutoFillEmptyCells = true; tabela.Border = 0; tabela.EndHeaders(); if(revista.DataPublicacao.HasValue && revista.DataPublicacao.Value != DateTime.MinValue) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout43.IdentificadorCampo + " " + revista.DataPublicacao.Value.ToString("dd/MM/yyyy"), _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (revista.DataDeDeposito.HasValue && revista.DataDeDeposito.Value != DateTime.MinValue) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout22.IdentificadorCampo + " " + revista.DataDeDeposito.Value.ToString("dd/MM/yyyy"), _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.NumeroProcessoDaPatente)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout11.IdentificadorCampo + " " + revista.NumeroProcessoDaPatente, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.NumeroDoPedido)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout21.IdentificadorCampo + " " + revista.NumeroDoProcessoFormatado, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (revista.DataDaPublicacaoDoPedido.HasValue && revista.DataDaPublicacaoDoPedido.Value != DateTime.MinValue) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout43.IdentificadorCampo + " " + revista.DataDaPublicacaoDoPedido.Value.ToString("dd/MM/yyyy"), _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (revista.DataDeConcessao.HasValue && revista.DataDeConcessao.Value != DateTime.MinValue) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout45.IdentificadorCampo + " " + revista.DataDeConcessao.Value.ToString("dd/MM/yyyy"), _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.PrioridadeUnionista)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout43.IdentificadorCampo + " " + revista.DataPublicacao.Value.ToString("dd/MM/yyyy"), _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.ClassificacaoInternacional)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout51.IdentificadorCampo + " " + revista.ClassificacaoInternacional, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Titulo)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout54.IdentificadorCampo + " " + revista.Titulo, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Resumo)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout57.IdentificadorCampo + " " + revista.Resumo, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.DadosDoPedidoDaPatente)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout61.IdentificadorCampo + " " + revista.DadosDoPedidoDaPatente, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.DadosDoPedidoOriginal)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout62.IdentificadorCampo + " " + revista.DadosDoPedidoOriginal, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.PrioridadeInterna)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout66.IdentificadorCampo + " " + revista.PrioridadeInterna, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Depositante)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout71.IdentificadorCampo + " " + revista.Depositante, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Inventor)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout72.IdentificadorCampo + " " + revista.Inventor, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Titular)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout73.IdentificadorCampo + " " + revista.Titular + " " + revista.UFTitular + " " + revista.PaisTitular, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Procurador)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout74.IdentificadorCampo + " " + revista.Procurador, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.PaisesDesignados)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout81.IdentificadorCampo + " " + revista.PaisesDesignados, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (revista.DataInicioFaseNacional.HasValue && revista.DataInicioFaseNacional.Value != DateTime.MinValue) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout85.IdentificadorCampo + " " + revista.DataInicioFaseNacional.Value.ToString("dd/MM/yyyy"), _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.DadosDepositoInternacional)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout86.IdentificadorCampo + " " + revista.DadosDepositoInternacional, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.DadosPublicacaoInternacional)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.Layout87.IdentificadorCampo + " " + revista.DadosPublicacaoInternacional, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.CodigoDoDespacho)) { var despacho = FabricaGenerica.GetInstancia().CrieObjeto<IDespachoDePatentes>(); using (var servico = FabricaGenerica.GetInstancia().CrieObjeto<IServicoDeDespachoDePatentes>()) despacho = servico.ObtenhaDespachoPeloCodigo(revista.CodigoDoDespacho); if(despacho != null) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutCD.IdentificadorCampo + " " + despacho.Codigo + " - " + despacho.Titulo, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } } if (!string.IsNullOrEmpty(revista.ResponsavelPagamentoImpostoDeRenda)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutRP.IdentificadorCampo + " " + revista.ResponsavelPagamentoImpostoDeRenda, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Complemento)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutCO.IdentificadorCampo + " " + revista.Complemento, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Decisao)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutDE.IdentificadorCampo + " " + revista.Decisao, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Recorrente)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutRE.IdentificadorCampo + " " + revista.Recorrente, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.NumeroDoProcesso)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutNP.IdentificadorCampo + " " + revista.NumeroDoProcessoFormatado, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Cedente)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutCE.IdentificadorCampo + " " + revista.Cedente, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Cessionaria)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutCS.IdentificadorCampo + " " + revista.Cessionaria, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.UltimaInformacao)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutUI.IdentificadorCampo + " " + revista.UltimaInformacao, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.CertificadoDeAverbacao)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutCA.IdentificadorCampo + " " + revista.CertificadoDeAverbacao, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.PaisCedente)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutPE.IdentificadorCampo + " " + revista.PaisCedente, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.PaisDaCessionaria)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutPS.IdentificadorCampo + " " + revista.PaisDaCessionaria, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Setor)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutSE.IdentificadorCampo + " " + revista.Setor, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.EnderecoDaCessionaria)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutES.IdentificadorCampo + " " + revista.EnderecoDaCessionaria, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.NaturezaDoDocumento)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutND.IdentificadorCampo + " " + revista.NaturezaDoDocumento, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.MoedaDePagamento)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutMO.IdentificadorCampo + " " + revista.MoedaDePagamento, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Valor)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutVA.IdentificadorCampo + " " + revista.Valor, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Pagamento)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutPG.IdentificadorCampo + " " + revista.Pagamento, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Prazo)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutPZ.IdentificadorCampo + " " + revista.Prazo, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.ServicosIsentosDeAverbacao)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutIA.IdentificadorCampo + " " + revista.ServicosIsentosDeAverbacao, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Criador)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutCR.IdentificadorCampo + " " + revista.Criador, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Linguagem)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutLG.IdentificadorCampo + " " + revista.Linguagem, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.CampoDeAplicacao)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutCP.IdentificadorCampo + " " + revista.CampoDeAplicacao, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.TipoDePrograma)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutTP.IdentificadorCampo + " " + revista.TipoDePrograma, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (revista.DataDaCriacao.HasValue && revista.DataDaCriacao.Value != DateTime.MinValue) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutDL.IdentificadorCampo + " " + revista.DataDaCriacao.Value.ToString("dd/MM/yyyy"), _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.RegimeDeGuarda)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutRG.IdentificadorCampo + " " + revista.RegimeDeGuarda, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Requerente)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutRQ.IdentificadorCampo + " " + revista.Requerente, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Redacao)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutRD.IdentificadorCampo + " " + revista.Redacao, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Criador)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutCR.IdentificadorCampo + " " + revista.Criador, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Criador)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutCR.IdentificadorCampo + " " + revista.Criador, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } if (!string.IsNullOrEmpty(revista.Criador)) { var celula = new Cell(new Phrase(" " + LayoutRevistaPatente.LayoutCR.IdentificadorCampo + " " + revista.Criador, _Fonte1)); celula.DisableBorderSide(0); tabela.AddCell(celula); } return tabela; }
private Table ObtenhaTabelaCelulaProcesso(IRevistaDePatente revista) { var tabela = new Table(1); var corBackgroudHeader = new Color(211, 211, 211); tabela.Widths = new Single[] { 100 }; tabela.Padding = 0; tabela.Spacing = 0; tabela.Width = 100; tabela.AutoFillEmptyCells = true; tabela.Border = 0; tabela.EndHeaders(); var celula1 = new Cell(new Phrase("Processo " + revista.NumeroDoProcessoFormatado, _Fonte3)); celula1.DisableBorderSide(0); celula1.BackgroundColor = corBackgroudHeader; tabela.AddCell(celula1); return tabela; }
private void EscrevaProcessosNoDocumentoSintetico() { var tabela = new Table(4); tabela.Widths = new Single[] { 60, 100, 60, 100 }; tabela.Padding = 1; tabela.Spacing = 0; tabela.Width = 100; tabela.AutoFillEmptyCells = true; tabela.DefaultCell.Border = Rectangle.NO_BORDER; var corBackgroudHeader = new Color(211, 211, 211); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Número do processo", _Fonte3, Cell.ALIGN_CENTER, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Patente", _Fonte3, Cell.ALIGN_LEFT, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Despacho", _Fonte3, Cell.ALIGN_CENTER, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Cliente", _Fonte3, Cell.ALIGN_LEFT, 0, corBackgroudHeader, true)); tabela.EndHeaders(); foreach (var processo in _processosPatentes) { tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.NumeroDoProcessoFormatado.ToString(), _Fonte1, Cell.ALIGN_CENTER, 0, false)); if (processo.Patente != null && !string.IsNullOrEmpty(processo.Patente.TituloPatente)) tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.Patente.TituloPatente, _Fonte1, Cell.ALIGN_LEFT, 0, false)); else tabela.AddCell(iTextSharpUtilidades.CrieCelula(string.Empty, _Fonte1, Cell.ALIGN_LEFT, 0, false)); tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.Despacho != null ? processo.Despacho.Codigo : "", _Fonte1, Cell.ALIGN_CENTER, 0, false)); string clientes = string.Empty; if (processo.Patente != null) { clientes = processo.Patente.Clientes.Aggregate(clientes, (current, cliente) => current + (cliente.Pessoa.Nome + " - ")); if (!string.IsNullOrEmpty(clientes)) clientes = clientes.Substring(0, clientes.Length - 3); } tabela.AddCell(iTextSharpUtilidades.CrieCelula(clientes, _Fonte1, Cell.ALIGN_LEFT, 0, false)); } _documento.Add(tabela); }
public void GenerateXMLReport() { try { this.doc.Open(); RenderLogo(); //RenderHeaderAddress(); RenderReportJobInfo(); RenderProjectsReports(); #region Add Details Table float[] DetailsHeaderwidths = this.Headerwidths; // percentage iTextSharp.text.Table JobDetailstable = new iTextSharp.text.Table(DetailsHeaderwidths.Length); JobDetailstable.Padding = 1; JobDetailstable.DefaultCell.BorderWidth = 1; JobDetailstable.Widths = DetailsHeaderwidths; JobDetailstable.WidthPercentage = 100; JobDetailstable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; JobDetailstable.DefaultCell.BackgroundColor = Color.LIGHT_GRAY; foreach (var x in this.ColList) { JobDetailstable.AddCell(new Phrase(x, fntHeading)); } JobDetailstable.EndHeaders(); Font myDetailFont = fntDetails; foreach (var x in this.ReportRows) { for (int i = 0; i < ColList.Count; i++) { JobDetailstable.DefaultCell.BackgroundColor = Color.WHITE; if(x.row[i].type == CellType.Number) JobDetailstable.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT; else JobDetailstable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; JobDetailstable.AddCell(new Phrase(x.row[i].value, myDetailFont)); } } JobDetailstable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; Cell cell = new Cell(new Paragraph("Total", myDetailFont)); cell.BackgroundColor = Color.LIGHT_GRAY; cell.BorderWidth = 1; cell.Colspan = 3; JobDetailstable.AddCell(cell); JobDetailstable.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT; JobDetailstable.DefaultCell.BackgroundColor = Color.LIGHT_GRAY; JobDetailstable.AddCell(new Phrase(this.total, myDetailFont)); doc.Add(JobDetailstable); #endregion } catch (Exception ex) { //MessageBox.Show("Error: " + ex.Message); } doc.Close(); writer.Close(); }
protected void Button1_Click(object sender, EventArgs e) { HttpContext.Current.Response.ContentType = "Application/PDF"; HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename= District_Master.pdf"); StringWriter sw = new StringWriter(); HtmlTextWriter tw = new HtmlTextWriter(sw); string qry1 = "select Dist_Code,Dist_Name from Dist_List order by Dist_Name"; SqlCommand cmd = new SqlCommand(qry1, con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); iTextSharp.text.Table tb = new iTextSharp.text.Table(2); tb.BorderWidth = 0.6f; tb.BorderColor = new Color(0, 0, 0); tb.CellsFitPage = true; tb.Padding = 2; tb.Width = 90; //Single widths = new Single() [ 5, 5]; //tb.Widths = widths; if (ds.Tables[0].Rows.Count > 0) { DataTable dt; dt = ds.Tables[0]; Paragraph p31 = new Paragraph("District Code", new Font(Font.TIMES_ROMAN, 11, Font.BOLD)); iTextSharp.text.Cell tcell_1 = new iTextSharp.text.Cell(p31); tcell_1.Header = true; tcell_1.HorizontalAlignment = Element.ALIGN_CENTER; tcell_1.BackgroundColor = Color.LIGHT_GRAY; tb.AddCell(tcell_1); tb.EndHeaders(); Paragraph p32 = new Paragraph("District Name", new Font(Font.TIMES_ROMAN, 11, Font.BOLD)); iTextSharp.text.Cell tcell_2 = new iTextSharp.text.Cell(p32); tcell_2.Header = true; tcell_2.HorizontalAlignment = Element.ALIGN_CENTER; tcell_2.BackgroundColor = Color.LIGHT_GRAY; tb.AddCell(tcell_2); tb.EndHeaders(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Paragraph p11; Paragraph p12; p11 = new Paragraph(ds.Tables[0].Rows[i]["Dist_Code"].ToString(), new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); p12 = new Paragraph(ds.Tables[0].Rows[i]["Dist_Name"].ToString(), new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); iTextSharp.text.Cell tcell_p111 = new iTextSharp.text.Cell(p11); tcell_p111.HorizontalAlignment = Element.ALIGN_CENTER; tb.AddCell(tcell_p111); iTextSharp.text.Cell tcell_p112 = new iTextSharp.text.Cell(p12); tcell_p112.HorizontalAlignment = Element.ALIGN_LEFT; tb.AddCell(tcell_p112); } } StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 2, 2, 2, 1); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, HttpContext.Current.Response.OutputStream); PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); String pcnt; pcnt = (writer.CurrentPageNumber - 1).ToString(); pcnt = pcnt.Substring(1); pdfDoc.Open(); pdfDoc.Add(new Paragraph(" DISTRICT MASTER")); pdfDoc.Add(tb); pdfDoc.Close(); HttpContext.Current.Response.Write(pdfDoc); HttpContext.Current.Response.End(); }
private void EscrevaProcessosNoDocumentoSintetico() { var tabela = new Table(4); tabela.Widths = new Single[] { 60, 100, 60, 100 }; tabela.Padding = 1; tabela.Spacing = 0; tabela.Width = 100; tabela.AutoFillEmptyCells = true; var corBackgroudHeader = new Color(211, 211, 211); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Número do processo", _Fonte2, Cell.ALIGN_CENTER, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Marca", _Fonte2, Cell.ALIGN_LEFT, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Despacho", _Fonte2, Cell.ALIGN_CENTER, 0, corBackgroudHeader, true)); tabela.AddCell(iTextSharpUtilidades.CrieCelula("Cliente", _Fonte2, Cell.ALIGN_LEFT, 0, corBackgroudHeader, true)); tabela.EndHeaders(); foreach (var processo in _processos) { tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.Processo.ToString(), _Fonte1, Cell.ALIGN_CENTER, 0, false)); if (processo.Marca != null && !string.IsNullOrEmpty(processo.Marca.DescricaoDaMarca)) tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.Marca.DescricaoDaMarca, _Fonte1, Cell.ALIGN_LEFT, 0, false)); else tabela.AddCell(iTextSharpUtilidades.CrieCelula(string.Empty, _Fonte1, Cell.ALIGN_LEFT, 0, false)); tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.Despacho != null ? processo.Despacho.CodigoDespacho : "", _Fonte1, Cell.ALIGN_CENTER, 0, false)); tabela.AddCell(iTextSharpUtilidades.CrieCelula(processo.Marca.Cliente.Pessoa.Nome, _Fonte1, Cell.ALIGN_LEFT, 0, false)); } _documento.Add(tabela); }
public void GenerateXMLReport() { try { this.doc.Open(); RenderLogo(); //RenderHeaderAddress(); RenderReportJobInfo(); RenderProjectsReports(); #region Add Details Table float[] DetailsHeaderwidths = this.Headerwidths; // percentage iTextSharp.text.Table JobDetailstable = new iTextSharp.text.Table(DetailsHeaderwidths.Length); JobDetailstable.Padding = 1; JobDetailstable.DefaultCell.BorderWidth = 1; JobDetailstable.Widths = DetailsHeaderwidths; JobDetailstable.WidthPercentage = 100; JobDetailstable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; JobDetailstable.DefaultCell.BackgroundColor = Color.LIGHT_GRAY; foreach (var x in this.ColList) { JobDetailstable.AddCell(new Phrase(x, fntHeading)); } JobDetailstable.EndHeaders(); Font myDetailFont = fntDetails; foreach (var x in this.ReportRows) { for (int i = 0; i < ColList.Count; i++) { JobDetailstable.DefaultCell.BackgroundColor = Color.WHITE; if (x.row[i].type == CellType.Number) { JobDetailstable.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT; } else { JobDetailstable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; } JobDetailstable.AddCell(new Phrase(x.row[i].value, myDetailFont)); } } JobDetailstable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; Cell cell = new Cell(new Paragraph("Total", myDetailFont)); cell.BackgroundColor = Color.LIGHT_GRAY; cell.BorderWidth = 1; cell.Colspan = 3; JobDetailstable.AddCell(cell); JobDetailstable.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT; JobDetailstable.DefaultCell.BackgroundColor = Color.LIGHT_GRAY; JobDetailstable.AddCell(new Phrase(this.total, myDetailFont)); doc.Add(JobDetailstable); #endregion } catch (Exception ex) { //MessageBox.Show("Error: " + ex.Message); } doc.Close(); writer.Close(); }
protected void btnpdf_Click(object sender, ImageClickEventArgs e) { HttpContext.Current.Response.ContentType = "Application/PDF"; HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename= MIS_Teacher.pdf"); StringWriter sw = new StringWriter(); HtmlTextWriter tw = new HtmlTextWriter(sw); if (ddltch.Text == "-All-") { string qry1 = "Select sms_teacher.Teacher_Name, sms_teacher.Teacher_ID, sms_teacher.Subject_Code, sms_subject_master.Subject_Name, sms_teacher.School_Code, sms_school_master.School_Name, sms_school_master.Dist_Code, Dist_List.Dist_Name from (((sms_teacher inner join sms_school_master on sms_teacher.School_Code = sms_school_master.School_Code) inner join Dist_List on sms_school_master.Dist_Code = Dist_List.Dist_Code) inner join sms_subject_master on sms_teacher.Subject_Code = sms_subject_master.Subject_ID) order by sms_teacher.Teacher_Name"; SqlCommand cmd = new SqlCommand(qry1, con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); iTextSharp.text.Table tb = new iTextSharp.text.Table(4); tb.BorderWidth = 0.6f; tb.BorderColor = new Color(0, 0, 0); tb.CellsFitPage = true; tb.Padding = 2; tb.Width = 90; //Single widths = new Single() [ 5, 5]; //tb.Widths = widths; if (ds.Tables[0].Rows.Count > 0) { DataTable dt; dt = ds.Tables[0]; Paragraph p31 = new Paragraph("Teacher", new Font(Font.TIMES_ROMAN, 11, Font.BOLD)); iTextSharp.text.Cell tcell_1 = new iTextSharp.text.Cell(p31); tcell_1.Header = true; tcell_1.HorizontalAlignment = Element.ALIGN_CENTER; tcell_1.BackgroundColor = Color.LIGHT_GRAY; tb.AddCell(tcell_1); tb.EndHeaders(); Paragraph p32 = new Paragraph("Subject", new Font(Font.TIMES_ROMAN, 11, Font.BOLD)); iTextSharp.text.Cell tcell_2 = new iTextSharp.text.Cell(p32); tcell_2.Header = true; tcell_2.HorizontalAlignment = Element.ALIGN_CENTER; tcell_2.BackgroundColor = Color.LIGHT_GRAY; tb.AddCell(tcell_2); tb.EndHeaders(); Paragraph p33 = new Paragraph("School", new Font(Font.TIMES_ROMAN, 11, Font.BOLD)); iTextSharp.text.Cell tcell_3 = new iTextSharp.text.Cell(p33); tcell_3.Header = true; tcell_3.HorizontalAlignment = Element.ALIGN_CENTER; tcell_3.BackgroundColor = Color.LIGHT_GRAY; tb.AddCell(tcell_3); tb.EndHeaders(); Paragraph p34 = new Paragraph("District", new Font(Font.TIMES_ROMAN, 11, Font.BOLD)); iTextSharp.text.Cell tcell_4 = new iTextSharp.text.Cell(p34); tcell_4.Header = true; tcell_4.HorizontalAlignment = Element.ALIGN_CENTER; tcell_4.BackgroundColor = Color.LIGHT_GRAY; tb.AddCell(tcell_4); tb.EndHeaders(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Paragraph p11; Paragraph p12; Paragraph p13; Paragraph p14; p11 = new Paragraph(ds.Tables[0].Rows[i]["Teacher_Name"].ToString(), new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); p12 = new Paragraph(ds.Tables[0].Rows[i]["Subject_Name"].ToString(), new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); p13 = new Paragraph(ds.Tables[0].Rows[i]["School_Name"].ToString(), new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); p14 = new Paragraph(ds.Tables[0].Rows[i]["Dist_Name"].ToString(), new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); iTextSharp.text.Cell tcell_p111 = new iTextSharp.text.Cell(p11); tcell_p111.HorizontalAlignment = Element.ALIGN_CENTER; tb.AddCell(tcell_p111); iTextSharp.text.Cell tcell_p112 = new iTextSharp.text.Cell(p12); tcell_p112.HorizontalAlignment = Element.ALIGN_CENTER; tb.AddCell(tcell_p112); iTextSharp.text.Cell tcell_p113 = new iTextSharp.text.Cell(p13); tcell_p113.HorizontalAlignment = Element.ALIGN_CENTER; tb.AddCell(tcell_p113); iTextSharp.text.Cell tcell_p114 = new iTextSharp.text.Cell(p14); tcell_p114.HorizontalAlignment = Element.ALIGN_CENTER; tb.AddCell(tcell_p114); } } StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 2, 2, 2, 1); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, HttpContext.Current.Response.OutputStream); PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); String pcnt; pcnt = (writer.CurrentPageNumber - 1).ToString(); pcnt = pcnt.Substring(1); pdfDoc.Open(); pdfDoc.Add(new Paragraph(" MIS Teachers")); pdfDoc.Add(tb); pdfDoc.Close(); HttpContext.Current.Response.Write(pdfDoc); HttpContext.Current.Response.End(); } else { string qry1 = "Select sms_teacher.Teacher_Name, sms_teacher.Teacher_ID, sms_teacher.Subject_Code, sms_subject_master.Subject_Name, sms_teacher.School_Code, sms_school_master.School_Name, sms_school_master.Dist_Code, Dist_List.Dist_Name from ((sms_teacher inner join sms_school_master on sms_teacher.School_Code = sms_school_master.School_Code) inner join Dist_List on sms_school_master.Dist_Code = Dist_List.Dist_Code) inner join sms_subject_master on sms_teacher.Subject_Code=sms_subject_master.Subject_ID) order by sms_teacher.Teacher_Name where sms_teacher.Teacher_ID='" + ddltch.SelectedItem.Value + "' "; SqlCommand cmd = new SqlCommand(qry1, con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); iTextSharp.text.Table tb = new iTextSharp.text.Table(4); tb.BorderWidth = 0.6f; tb.BorderColor = new Color(0, 0, 0); tb.CellsFitPage = true; tb.Padding = 2; tb.Width = 90; //Single widths = new Single() [ 5, 5]; //tb.Widths = widths; if (ds.Tables[0].Rows.Count > 0) { DataTable dt; dt = ds.Tables[0]; Paragraph p31 = new Paragraph("Teacher", new Font(Font.TIMES_ROMAN, 11, Font.BOLD)); iTextSharp.text.Cell tcell_1 = new iTextSharp.text.Cell(p31); tcell_1.Header = true; tcell_1.HorizontalAlignment = Element.ALIGN_CENTER; tcell_1.BackgroundColor = Color.LIGHT_GRAY; tb.AddCell(tcell_1); tb.EndHeaders(); Paragraph p32 = new Paragraph("Subject", new Font(Font.TIMES_ROMAN, 11, Font.BOLD)); iTextSharp.text.Cell tcell_2 = new iTextSharp.text.Cell(p32); tcell_2.Header = true; tcell_2.HorizontalAlignment = Element.ALIGN_CENTER; tcell_2.BackgroundColor = Color.LIGHT_GRAY; tb.AddCell(tcell_2); tb.EndHeaders(); Paragraph p33 = new Paragraph("School", new Font(Font.TIMES_ROMAN, 11, Font.BOLD)); iTextSharp.text.Cell tcell_3 = new iTextSharp.text.Cell(p33); tcell_3.Header = true; tcell_3.HorizontalAlignment = Element.ALIGN_CENTER; tcell_3.BackgroundColor = Color.LIGHT_GRAY; tb.AddCell(tcell_3); tb.EndHeaders(); Paragraph p34 = new Paragraph("District", new Font(Font.TIMES_ROMAN, 11, Font.BOLD)); iTextSharp.text.Cell tcell_4 = new iTextSharp.text.Cell(p34); tcell_4.Header = true; tcell_4.HorizontalAlignment = Element.ALIGN_CENTER; tcell_4.BackgroundColor = Color.LIGHT_GRAY; tb.AddCell(tcell_4); tb.EndHeaders(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Paragraph p11; Paragraph p12; Paragraph p13; Paragraph p14; p11 = new Paragraph(ds.Tables[0].Rows[i]["Teacher_Name"].ToString(), new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); p12 = new Paragraph(ds.Tables[0].Rows[i]["Subject_Name"].ToString(), new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); p13 = new Paragraph(ds.Tables[0].Rows[i]["School_Name"].ToString(), new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); p14 = new Paragraph(ds.Tables[0].Rows[i]["Dist_Name"].ToString(), new Font(Font.TIMES_ROMAN, 10, Font.NORMAL)); iTextSharp.text.Cell tcell_p111 = new iTextSharp.text.Cell(p11); tcell_p111.HorizontalAlignment = Element.ALIGN_CENTER; tb.AddCell(tcell_p111); iTextSharp.text.Cell tcell_p112 = new iTextSharp.text.Cell(p12); tcell_p112.HorizontalAlignment = Element.ALIGN_CENTER; tb.AddCell(tcell_p112); iTextSharp.text.Cell tcell_p113 = new iTextSharp.text.Cell(p13); tcell_p113.HorizontalAlignment = Element.ALIGN_CENTER; tb.AddCell(tcell_p113); iTextSharp.text.Cell tcell_p114 = new iTextSharp.text.Cell(p14); tcell_p114.HorizontalAlignment = Element.ALIGN_CENTER; tb.AddCell(tcell_p114); } } StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 2, 2, 2, 1); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, HttpContext.Current.Response.OutputStream); PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); String pcnt; pcnt = (writer.CurrentPageNumber - 1).ToString(); pcnt = pcnt.Substring(1); pdfDoc.Open(); pdfDoc.Add(new Paragraph(" MIS Teachers")); pdfDoc.Add(tb); pdfDoc.Close(); HttpContext.Current.Response.Write(pdfDoc); HttpContext.Current.Response.End(); } }
public void GenerateXMLReport() { try { this.doc.Open(); RenderLogo(); RenderDescription(); RenderReportJobInfo(); iTextSharp.text.Table myTable = new iTextSharp.text.Table(ColList.Count); myTable.Widths = this.Headerwidths; myTable.WidthPercentage = 100; //myTable.Locked = true; //Render Table Headers~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ myTable.DefaultLayout.HorizontalAlignment = Element.ALIGN_LEFT; myTable.DefaultCell.BorderWidth = ReportBorderWidth; myTable.Cellpadding = 1; myTable.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE; myTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; myTable.DefaultCell.BackgroundColor = Color.LIGHT_GRAY; myTable.DefaultCell.UseBorderPadding = true; foreach (var x in this.ColList) { myTable.AddCell(new Phrase(x, fntHeading)); } myTable.EndHeaders(); //Render Details~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Font myDetailFont = fntDetails; foreach (var x in this.ReportRows) { for (int i = 0; i < ColList.Count; i++) { myTable.DefaultCell.BackgroundColor = Color.WHITE; if (x.row[i].type == CellType.Number) { myTable.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT; } else { myTable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; } if (i > ColList.Count - 3) { myTable.DefaultCell.BackgroundColor = Color.LIGHT_GRAY; } else { myTable.DefaultCell.BackgroundColor = Color.WHITE; } if (i == ColList.Count - 3) { myTable.AddCell(new Phrase(x.row[i].value, footerFont)); } else { myTable.AddCell(new Phrase(x.row[i].value, myDetailFont)); } } } //Footer Totals~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ myTable.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT; myTable.DefaultCell.BackgroundColor = Color.WHITE; myTable.DefaultCell.Colspan = 4; myTable.AddCell(new Phrase("Totals", footerFont)); myTable.DefaultCell.Colspan = 1; for (int i = 4; i < FooterList.Count; i++) { myTable.AddCell(new Phrase(FooterList[i], footerFont)); //if ((FooterList[i].Length > 0 && SacoList[i].Length > 0) && (decimal.Parse(FooterList[i]) > decimal.Parse(SacoList[i]))) //{ // myTable.AddCell(new Phrase(FooterList[i], ErrorFont)); //} //else //{ // if (SacoList[i].Trim().Length == 0) // myTable.AddCell(new Phrase(FooterList[i], ErrorFont)); // else // myTable.AddCell(new Phrase(FooterList[i], footerFont)); //} } //Render Saco Totals~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ myTable.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT; myTable.DefaultCell.BackgroundColor = Color.BLUE; myTable.DefaultCell.Colspan = 4; myTable.AddCell(new Phrase("Saco Hours", SacoFont)); myTable.DefaultCell.Colspan = 1; for (int i = 4; i < SacoList.Count; i++) { myTable.AddCell(new Phrase(SacoList[i], SacoFont)); } //Render Diff Totals~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ myTable.DefaultCell.HorizontalAlignment = Element.ALIGN_RIGHT; myTable.DefaultCell.BackgroundColor = Color.WHITE; myTable.DefaultCell.Colspan = 4; myTable.AddCell(new Phrase("Diff", footerFont)); myTable.DefaultCell.Colspan = 1; decimal diff = 0M; string cellvalue = ""; decimal sacovalue = 0M; decimal footervalue = 0M; for (int i = 4; i < SacoList.Count; i++) { diff = 0M; sacovalue = (SacoList[i].Length > 0)? decimal.Parse(SacoList[i]) : 0M; footervalue = (FooterList[i].Length > 0) ? decimal.Parse(FooterList[i]) : 0M; diff = sacovalue - footervalue; cellvalue = (diff == 0) ? string.Empty : diff.ToString("#0.00"); myTable.AddCell(new Phrase(cellvalue, footerFont)); } //Put in a blank line~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //myTable.DefaultCell.BorderWidth = 0; //myTable.DefaultCell.BackgroundColor = Color.WHITE; //for (int row = 0; row < 10; row++) //{ // for (int i = 0; i < this.SacoList.Count; i++) // { // myTable.AddCell(new Phrase(" ", fntDetails)); // } //} doc.Add(myTable); //Render Signature Section~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //RenderSignatueSection(); #endregion } catch (Exception ex) { throw (new Exception("Error: " + ex.Message)); } doc.Close(); writer.Close(); }