public UserReport() { doc = new Document(PageSize.A4.Rotate(), 35, 35, 35, 35); writer = PdfWriter.GetInstance(doc, ms); MyPageEvents events = new MyPageEvents(); writer.PageEvent = events; }
//public Report() //{ // fntHeading = FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.BOLD, new Color(0x00, 0x00, 0x00)); // fntDetails = FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.NORMAL, new Color(0x00, 0x00, 0x00)); // bf = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED); // doc = new Document(PageSize.A4 , 35, 35, 35, 35); // writer = PdfWriter.GetInstance(doc, ms); // MyPageEvents events = new MyPageEvents(); // writer.PageEvent = events; //} public Report(bool Landscape) { fntHeading = FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.BOLD, new Color(0x00, 0x00, 0x00)); fntDetails = FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.NORMAL, new Color(0x00, 0x00, 0x00)); bf = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED); if(Landscape) doc = new Document(PageSize.A4.Rotate(), 35, 35, 35, 35); else doc = new Document(PageSize.A4, 35, 35, 35, 35); writer = PdfWriter.GetInstance(doc, ms); MyPageEvents events = new MyPageEvents(); writer.PageEvent = events; }
//public Report() //{ // fntHeading = FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.BOLD, new Color(0x00, 0x00, 0x00)); // fntDetails = FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.NORMAL, new Color(0x00, 0x00, 0x00)); // bf = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED); // doc = new Document(PageSize.A4 , 35, 35, 35, 35); // writer = PdfWriter.GetInstance(doc, ms); // MyPageEvents events = new MyPageEvents(); // writer.PageEvent = events; //} public Report(bool Landscape) { fntHeading = FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.BOLD, new Color(0x00, 0x00, 0x00)); fntDetails = FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.NORMAL, new Color(0x00, 0x00, 0x00)); bf = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED); if (Landscape) { doc = new Document(PageSize.A4.Rotate(), 35, 35, 35, 35); } else { doc = new Document(PageSize.A4, 35, 35, 35, 35); } writer = PdfWriter.GetInstance(doc, ms); MyPageEvents events = new MyPageEvents(); writer.PageEvent = events; }
public IlithaTimeSheetReport(bool Landscape) { fntHeading = FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.BOLD, new Color(0x00, 0x00, 0x00)); fntDetails = FontFactory.GetFont(FontFactory.HELVETICA, 5, Font.NORMAL, new Color(0x00, 0x00, 0x00)); footerFont = FontFactory.GetFont(FontFactory.HELVETICA, 5, Font.BOLD, new Color(0x00, 0x00, 0x00)); SacoFont = FontFactory.GetFont(FontFactory.HELVETICA, 5, Font.BOLD, new Color(0xFF, 0xFF, 0xFF)); ErrorFont = FontFactory.GetFont(FontFactory.HELVETICA, 5, Font.BOLD, new Color(0xFF, 0x00, 0x00)); ReportBorderWidth = 0.5F; bf = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED); if (Landscape) doc = new Document(PageSize.A4.Rotate(), 18, 18, 18, 100); else doc = new Document(PageSize.A4, 18, 18, 18, 100); writer = PdfWriter.GetInstance(doc, ms); MyPageEvents events = new MyPageEvents(); writer.PageEvent = events; }
public IlithaTimeSheetReport(bool Landscape) { fntHeading = FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.BOLD, new Color(0x00, 0x00, 0x00)); fntDetails = FontFactory.GetFont(FontFactory.HELVETICA, 5, Font.NORMAL, new Color(0x00, 0x00, 0x00)); footerFont = FontFactory.GetFont(FontFactory.HELVETICA, 5, Font.BOLD, new Color(0x00, 0x00, 0x00)); SacoFont = FontFactory.GetFont(FontFactory.HELVETICA, 5, Font.BOLD, new Color(0xFF, 0xFF, 0xFF)); ErrorFont = FontFactory.GetFont(FontFactory.HELVETICA, 5, Font.BOLD, new Color(0xFF, 0x00, 0x00)); ReportBorderWidth = 0.5F; bf = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED); if (Landscape) { doc = new Document(PageSize.A4.Rotate(), 18, 18, 18, 100); } else { doc = new Document(PageSize.A4, 18, 18, 18, 100); } writer = PdfWriter.GetInstance(doc, ms); MyPageEvents events = new MyPageEvents(); writer.PageEvent = events; }
private void Crear_Archivo(int intTotalPaginas) { Font ftProductos = new Font(FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.NORMAL)); int intMaxWidth = 190, intMaxHeight = 50, intLogoWidth, intLogoHeight; HttpCookie ckSIAN = Request.Cookies["userCng"]; int intNombreLogo = ckSIAN["ck_logo"].LastIndexOf("/") + 1; string[] strSize = ckSIAN["ck_logo_size"].Split('x'); intLogoWidth = int.Parse(strSize[0]); intLogoHeight = int.Parse(strSize[1]); float flRelacion = CRutinas.Calcular_Relacion(intMaxWidth, intMaxHeight, intLogoWidth, intLogoHeight); MyPageEvents events = new MyPageEvents(); events.strMapPath = Server.MapPath("../imagenes") + "/"; events.strLogoEmpresa = ckSIAN["ck_logo"].Substring(intNombreLogo); events.flEscala = flRelacion * 100; events.strCotizacion = this.strCotizacion; events.strRazonSocial = this.strRazonSocial; events.strRFC = this.strRFC; events.strTelefono = this.strTelefono; events.strEmail = this.strEmail; events.objDirEmisor = this.objDirEmisor; events.strNumeroCliente = this.strNumeroCliente; events.strCliente = this.strCliente; events.strClienteRFC = this.strClienteRFC; events.strDiasCredito = this.strDiasCredito; events.objDirReceptor = this.objDirReceptor; events.objEnvio = this.objEnvio; events.strEjecutivoVentas = this.strEjecutivoVentas; events.dtFecha = this.dtFecha; events.strNota = this.strNota; events.strOrdenCompra = this.strOrdenCompra; events.strContacto = this.strContacto; events.dcmSubtotal = this.dcmSubtotal; events.dcmDescuento = this.dcmDescuento; events.dcmIVA = this.dcmIVA; events.dcmTotal = this.dcmTotal; events.strMoneda = this.strMoneda; events.intTotalPaginas = intTotalPaginas; string strArchivoFormato = Server.MapPath("remision_ipisa.pdf"); PdfReader pdfEntrada = new PdfReader(strArchivoFormato); MemoryStream m = new MemoryStream(); Document document = new Document( new Rectangle(PageSize.LETTER.Width, PageSize.LETTER.Height)); // 1 in = 25.4 mm = 72 points document.SetMargins(32.0f, 32.0f, 290.0f, 135.0f); Response.ContentType = "application/pdf"; PdfWriter writer; string strArchivo = "remision_" + Request.QueryString["notID"] + ".pdf"; if (Request.QueryString["m"] == null) { writer = PdfWriter.GetInstance(document, m); writer.CloseStream = false; } else { FileStream flArchivo = new FileStream(Server.MapPath("../xml_facturas" + HttpContext.Current.Request.ApplicationPath + "/" + strArchivo), FileMode.Create); writer = PdfWriter.GetInstance(document, flArchivo); } writer.PageEvent = events; events.pdfPage1 = writer.GetImportedPage(pdfEntrada, 1); document.Open(); float[] ancho_columnas = new float[6]; ancho_columnas[0] = 50; ancho_columnas[1] = 75; ancho_columnas[2] = 242; ancho_columnas[3] = 63; ancho_columnas[4] = 62; ancho_columnas[5] = 74; char tab = '\u0009'; foreach (CProducto objProducto in this.lstProductos) { PdfPTable tblLinea = new PdfPTable(ancho_columnas); tblLinea.TotalWidth = 532; tblLinea.DefaultCell.Border = Rectangle.NO_BORDER; tblLinea.HorizontalAlignment = Element.ALIGN_LEFT; tblLinea.LockedWidth = true; Paragraph texto = new Paragraph(string.Empty, ftProductos); PdfPCell celda = new PdfPCell(texto); celda.HorizontalAlignment = Element.ALIGN_RIGHT; celda.Border = Rectangle.NO_BORDER; tblLinea.AddCell(celda); texto = new Paragraph(objProducto.StrCodigo, ftProductos); celda = new PdfPCell(texto); celda.HorizontalAlignment = Element.ALIGN_LEFT; celda.Border = Rectangle.NO_BORDER; tblLinea.AddCell(celda); if (!string.IsNullOrEmpty(objProducto.StrDetalle)) texto = new Paragraph(objProducto.StrDescripcion + "\n" + objProducto.StrDetalle.Replace(tab.ToString(), " "), ftProductos); else texto = new Paragraph(objProducto.StrDescripcion, ftProductos); celda = new PdfPCell(texto); celda.HorizontalAlignment = Element.ALIGN_LEFT; celda.Border = Rectangle.NO_BORDER; if (objProducto.IntGrupoID == 0) celda.PaddingLeft = 0; else celda.PaddingLeft = 10; tblLinea.AddCell(celda); texto = new Paragraph((objProducto.SwKit ? string.Empty : objProducto.AmtCantidad.ToString("0.##")), ftProductos); celda = new PdfPCell(texto); celda.HorizontalAlignment = Element.ALIGN_RIGHT; celda.Border = Rectangle.NO_BORDER; tblLinea.AddCell(celda); texto = new Paragraph((objProducto.SwKit ? string.Empty : objProducto.AmtValorUnitario.ToString("c")), ftProductos); celda = new PdfPCell(texto); celda.HorizontalAlignment = Element.ALIGN_RIGHT; celda.Border = Rectangle.NO_BORDER; tblLinea.AddCell(celda); texto = new Paragraph((objProducto.SwKit ? string.Empty : objProducto.AmtImporte.ToString("c")), ftProductos); celda = new PdfPCell(texto); celda.HorizontalAlignment = Element.ALIGN_RIGHT; celda.Border = Rectangle.NO_BORDER; tblLinea.AddCell(celda); document.Add(tblLinea); } document.Close(); if (Request.QueryString["m"] == null) { Response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length); Response.OutputStream.Flush(); Response.OutputStream.Close(); Response.End(); m.Close(); } else Response.Redirect("cotizacion_correo.aspx?t=c&c=" + Request.QueryString["notID"] + "&f=" + strArchivo); }
public bool CreateReport(DataTable rows) { bool isSuccessful = false; if (rows == null) { reportObject.ReportError = ReportConstants.NODATA; reportObject.ReportErrorLevel = (int)LogLevel.INFO; return(false); } iTextSharp.text.Document document = new iTextSharp.text.Document(_pageSize); try { //set up RunReport event overrides & create doc string reportFileName = Path.GetFullPath(reportObject.ReportTempFileFullName); if (!Directory.Exists(Path.GetDirectoryName(reportFileName))) { Directory.CreateDirectory(Path.GetDirectoryName(reportFileName)); } PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(reportFileName, FileMode.Create)); MyPageEvents eventMgr = new MyPageEvents { footer = _footer, disclaimer = _disclaimer }; writer.PageEvent = eventMgr; PdfPTable table = new PdfPTable(headers.Count); Image gif = Image.GetInstance(Common.Properties.Resources.logo, BaseColor.WHITE); gif.ScalePercent(35); _reportFont = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL); document.AddTitle(reportObject.ReportTitle); document.SetPageSize(_pageSize); document.SetMargins(-50, -50, 10, 45); PrintReportHeader(table, gif); // Print Headings columnWidths = new float[headers.Count]; for (int i = 0; i < headers.Count; i++) { columnWidths[i] = headers[i].width; } table.SetWidthPercentage(columnWidths, _pageSize); foreach (heading h in headers) { int alignment = (h.header_align >= 0) ? h.header_align : h.align; PdfPCell cell = new PdfPCell(new Paragraph(h.text, _reportFont)) { Border = Rectangle.BOTTOM_BORDER, HorizontalAlignment = alignment, VerticalAlignment = Element.ALIGN_TOP, }; table.AddCell(cell); } table.HeaderRows = table.Rows.Count; int group_count = 0; // only used if report has a groupByTitle & groupBy Fields string lastGroup = ""; string nxtGroup = ""; bool breakGroup = false; int nrGroupByFields = 0; // Print Report Details for (int rowIter = 0; rowIter < rows.Rows.Count; rowIter++) { DataRow row = rows.Rows[rowIter]; for (int i = 0; i < headers.Count; i++) { heading h = headers[i]; int alignment = (h.field_align >= 0) ? h.field_align : h.align; if (!rows.Columns.Contains(h.fieldName)) { reportObject.ReportError = "Application Field (" + h.fieldName + ") not in the returned data."; reportObject.ReportErrorLevel = (int)LogLevel.FATAL; throw new Exception("FieldConfig"); } string value = ""; if (h.Translator != null) { value = h.Translator(row[h.fieldName]); } else { value = String.Format(h.format, row[h.fieldName]); } PdfPCell cell = new PdfPCell(new Phrase(value, _reportFont)); if (h.formatICN) { cell = this.GetFormattedICNCell(value); } cell.HorizontalAlignment = alignment; cell.Border = Rectangle.NO_BORDER; table.AddCell(cell); if (h.groupBy) { group_count++; if (lastGroup.Length == 0) { nrGroupByFields++; lastGroup = row[h.fieldName].ToString(); } if (rowIter + 1 < rows.Rows.Count && !lastGroup.Equals(rows.Rows[rowIter + 1][h.fieldName].ToString())) { breakGroup = true; nxtGroup = rows.Rows[rowIter + 1][h.fieldName].ToString(); } } if (h.showTotal) { decimal ttl = 0; bool didParse = decimal.TryParse(row[h.fieldName].ToString(), out ttl); if (didParse) { h.total += ttl; h.groupTotal += ttl; headers[i] = h; if (rowIter == 0) { nrTotalFields++; } } } } if (breakGroup) { printGroupFooter(table, lastGroup, group_count); group_count = 0; lastGroup = nxtGroup; breakGroup = false; } } if (!string.IsNullOrEmpty(GroupByFooterTitle) && nrGroupByFields > 0) { printGroupFooter(table, lastGroup, group_count); } if (!String.IsNullOrEmpty(_totalLabel)) { PrintReportFooter(table); } table.AddCell(new PdfPCell { Colspan = headers.Count, Border = Rectangle.NO_BORDER }); new RunReport().ReportLines(table, true, "", true, _reportFont); // End of Report message document.Open(); document.Add(table); document.Close(); isSuccessful = true; } catch (DocumentException de) { reportObject.ReportError = de.Message; reportObject.ReportErrorLevel = (int)LogLevel.ERROR; } catch (IOException ioe) { reportObject.ReportError = ioe.Message; reportObject.ReportErrorLevel = (int)LogLevel.ERROR; } catch (Exception e) { reportObject.ReportError = e.Message; reportObject.ReportErrorLevel = (int)LogLevel.ERROR; } return(isSuccessful); }
private void Crear_Archivo(int intTotalPaginas) { int intMaxWidth = 190, intMaxHeight = 50, intLogoWidth, intLogoHeight; HttpCookie ckSIAN = Request.Cookies["userCng"]; int intNombreLogo = ckSIAN["ck_logo"].LastIndexOf("/") + 1; string[] strSize = ckSIAN["ck_logo_size"].Split('x'); intLogoWidth = int.Parse(strSize[0]); intLogoHeight = int.Parse(strSize[1]); float flRelacion = CRutinas.Calcular_Relacion(intMaxWidth, intMaxHeight, intLogoWidth, intLogoHeight); Font ftProductos = new Font(FontFactory.GetFont(FontFactory.HELVETICA, 6, Font.NORMAL)); MyPageEvents events = new MyPageEvents(); events._strNotaID = strNotaID; events._strContacto = strContacto; events._strCertificado = objFactura.StrCertificadoSAT; events._strFolioFiscal = objFactura.StrFolioFiscal; events._strSelloCFDI = objFactura.StrSelloCFDI; events._strSelloSAT = objFactura.StrSelloSAT; events._strCadenaOriginal = "N/A"; events._intFolio = objFactura.IntFolio; events._dtFechaCertificado = objFactura.DtFechaCertificado; events._intNoAprobacion = objFactura.IntNoAprobacion; events._intAnoAprobacion = objFactura.IntAnoAprobacion; events._strMetodoDePago = objFactura.StrMetodoDePago; events._strCondicionesDePago = objFactura.StrCondicionesDePago; events._amtSubTotal = objFactura.AmtSubTotal; events._amtDescuento = objFactura.AmtDescuento; events._amtTotal = objFactura.AmtTotal; events._strTotalLetras = CRutinas.ObtenerImporteLetras(objFactura.AmtTotal, objFactura.StrMoneda); events._strRFCEmisor = objFactura.StrRFCEmisor; events._strNombreEmisor = objFactura.StrNombreEmisor; events._dirDomicilioFiscal = objFactura.DirDomicilioFiscal; events._dirDomicilioExpedicion = objFactura.DirDomicilioExpedicion; events._strRFCCliente = objFactura.StrRFCCliente; events._strNombreCliente = objFactura.StrNombreCliente; events._strCedulaFiscalCliente = objFactura.StrCedulaFiscalCliente; events._strCedulaIEPSCliente = objFactura.StrCedulaIEPSCliente; events._dirDomicilioCliente = objFactura.DirDomicilioCliente; events._amtTotalImpuestosRetenidos = objFactura.AmtTotalImpuestosRetenidos; events._amtImpuesto = objFactura.AmtImpuesto; events._amtTasa = objFactura.AmtTasa; events._amtImporte = objFactura.AmtImporte; events._amtTotalImpuestos = objFactura.AmtTotalImpuestos; events._strMapPath = Server.MapPath("../imagenes") + "/"; events._strLogoEmpresa = ckSIAN["ck_logo"].Substring(intNombreLogo); events._flEscala = flRelacion * 100; events._intTotalPaginas = intTotalPaginas; events._strOrdenCompra = string.Empty; events._strProveedor = strProveedor; events._strVendedor = strVendedor; MemoryStream m = new MemoryStream(); Document document = new Document( new Rectangle(PageSize.LETTER.Width, PageSize.LETTER.Height)); // 1 in = 25.4 mm = 72 points document.SetMargins(32.0f, 32.0f, 205.0f, 150.0f); Response.ContentType = "application/pdf"; PdfWriter writer = PdfWriter.GetInstance(document, m); writer.CloseStream = false; writer.PageEvent = events; document.Open(); float[] ancho_columnas = new float[5]; ancho_columnas[0] = 60; ancho_columnas[1] = 10; ancho_columnas[2] = 335; ancho_columnas[3] = 73; ancho_columnas[4] = 60; foreach (CProducto objProducto in objFactura.LstProductos) { PdfPTable tblLinea = new PdfPTable(ancho_columnas); tblLinea.TotalWidth = 548; tblLinea.DefaultCell.Border = Rectangle.NO_BORDER; tblLinea.HorizontalAlignment = Element.ALIGN_LEFT; tblLinea.LockedWidth = true; Paragraph texto = new Paragraph((objProducto.SwKit ? string.Empty : objProducto.AmtCantidad.ToString("0.##")), ftProductos); PdfPCell celda = new PdfPCell(texto); celda.HorizontalAlignment = Element.ALIGN_RIGHT; celda.Border = Rectangle.NO_BORDER; tblLinea.AddCell(celda); texto = new Paragraph(string.Empty, ftProductos); celda = new PdfPCell(texto); celda.HorizontalAlignment = Element.ALIGN_LEFT; celda.Border = Rectangle.NO_BORDER; tblLinea.AddCell(celda); texto = new Paragraph(objProducto.StrDescripcion, ftProductos); celda = new PdfPCell(texto); celda.HorizontalAlignment = Element.ALIGN_LEFT; celda.Border = Rectangle.NO_BORDER; if (objProducto.IntGrupoID == 0) { celda.PaddingLeft = 0; } else { celda.PaddingLeft = 10; } tblLinea.AddCell(celda); texto = new Paragraph((objProducto.SwKit ? string.Empty : objProducto.AmtValorUnitario.ToString("c")), ftProductos); celda = new PdfPCell(texto); celda.HorizontalAlignment = Element.ALIGN_RIGHT; celda.Border = Rectangle.NO_BORDER; tblLinea.AddCell(celda); texto = new Paragraph((objProducto.SwKit ? string.Empty : objProducto.AmtImporte.ToString("c")), ftProductos); celda = new PdfPCell(texto); celda.HorizontalAlignment = Element.ALIGN_RIGHT; celda.Border = Rectangle.NO_BORDER; tblLinea.AddCell(celda); document.Add(tblLinea); } document.Close(); Response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length); Response.OutputStream.Flush(); Response.OutputStream.Close(); Response.End(); m.Close(); }