Пример #1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            //Para generar reporte genera un objeto de clase
            Reporte R = new Reporte();
            //Genera un documento horizontal
            Document doc = R.CreaDoc(false);

            //Usa la fuente segun se requiera
            //Fuente para titulo
            iTextSharp.text.Font _standardFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 10);
            iTextSharp.text.Font font          = R.Fuente(_standardFont);
            //Fuente para encabezados
            iTextSharp.text.Font _EncstandardFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 6);
            iTextSharp.text.Font fontEnc          = R.Fuente(_EncstandardFont);
            //Generar un writer para el reporte
            var writer = R.CreaWriter(doc);

            //Inicia la apertura del documento y escritura
            R.Iniciar(doc);
            //Titulo
            R.Titulo(doc, "Reportes de productos facturados y bonificados", font);
            // Inserta imagen EN DESARROLLO
            //Image img = R.Imagen();
            //R.SetImagen(img, doc);
            //Settear anchos de la tabla en base a los encabezados
            //Se debe tener el numero exacto de encabezados que se presentan
            float[] widths = new float[] { 2f, 2f, 2f, 2f, 2f, 2f, 2f, 2f,
                                           2f, 2f, 2f, 2f, 2f, 2f, 2f };
            //Se cambia la fuente para el contenidol reporte
            _standardFont = FontFactory.GetFont(FontFactory.HELVETICA, 6);
            font          = R.Fuente(_standardFont);
            // Lista de encabezados y contenido para reporte
            // desde el datagridView
            R.CreaReport(dataGridView1, font, fontEnc, doc, writer, widths);
        }
Пример #2
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            //Para generar reporte genera un objeto de clase
            Reporte R = new Reporte();
            //Genera un documento horizontal
            Document doc = R.CreaDoc(false);
            //Usa la fuente segun se requiera
            //Fuente para titulo
            Font _standardFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 16);
            Font font          = R.Fuente(_standardFont);
            //Fuente para encabezados
            Font _EncstandardFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 6);
            Font fontEnc          = R.Fuente(_EncstandardFont);
            //Generar un writer para el reporte
            var writer = R.CreaWriter(doc);

            //Inicia la apertura del documento y escritura
            R.Iniciar(doc);
            //Titulo
            R.Titulo(doc, "ENTREGA DE PRODUCTO EXCEDENTE", font);

            #region Cabecera
            // Ancho de clmn
            float[] widths  = new float[] { 7f, 9f, 3f, 3f };
            float[] widths0 = new float[] { 4.5f, 2f };
            var     para    = new Paragraph();
            para.Alignment = 2;
            para.Font.Size = 12;
            doc.Add(para);

            var cell1  = new PdfPCell();
            var phrase = new Phrase();
            phrase.Add(new Chunk("Orden produccion: ", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12)));
            phrase.Add(new Chunk(dataGridView1.Rows[0].Cells[0].Value.ToString(), FontFactory.GetFont(FontFactory.HELVETICA, 12)));
            cell1.AddElement(phrase);

            var cell2   = new PdfPCell();
            var phrase2 = new Phrase();
            phrase2.Add(new Chunk("Entrega Parcial: ", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12)));
            phrase2.Add(new Chunk(dataGridView1.Rows[0].Cells[1].Value.ToString(), FontFactory.GetFont(FontFactory.HELVETICA, 12)));
            cell2.AddElement(phrase2);

            var cell3   = new PdfPCell();
            var phrase3 = new Phrase();
            phrase3.Add(new Chunk("Cantidad a producir: ", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12)));
            phrase3.Add(new Chunk(dataGridView1.Rows[0].Cells[7].Value.ToString(), FontFactory.GetFont(FontFactory.HELVETICA, 12)));
            cell3.AddElement(phrase3);

            var cell4   = new PdfPCell();
            var phrase4 = new Phrase();
            phrase4.Add(new Chunk("# Lote: ", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12)));
            phrase4.Add(new Chunk(dataGridView1.Rows[0].Cells[10].Value.ToString(), FontFactory.GetFont(FontFactory.HELVETICA, 12)));
            cell4.AddElement(phrase4);

            var cell5   = new PdfPCell();
            var phrase5 = new Phrase();
            phrase5.Add(new Chunk("Pedido: ", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12)));
            phrase5.Add(new Chunk(dataGridView1.Rows[0].Cells[6].Value.ToString(), FontFactory.GetFont(FontFactory.HELVETICA, 12)));
            cell5.AddElement(phrase5);

            PdfPTable table0 = new PdfPTable(2);
            table0.LockedWidth = true;
            table0.TotalWidth  = 525f;
            PdfPCell cell0 = new PdfPCell();
            cell1.Border  = PdfPCell.NO_BORDER;
            cell2.Border  = PdfPCell.NO_BORDER;
            cell3.Border  = PdfPCell.NO_BORDER;
            cell4.Border  = PdfPCell.NO_BORDER;
            cell5.Border  = PdfPCell.NO_BORDER;
            cell0.Colspan = 2;
            table0.AddCell(cell1);
            table0.AddCell(cell2);
            table0.AddCell(cell3);
            table0.AddCell(cell4);
            table0.AddCell(cell5);
            table0.SetWidths(widths0);

            doc.Add(table0);
            #endregion

            #region Detalle
            PdfPTable table = new PdfPTable(4);
            PdfPCell  cell  = new PdfPCell();
            cell.Colspan             = 4;
            cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
            table.LockedWidth        = true;
            table.TotalWidth         = 525f;
            table.SpacingBefore      = 20f;
            table.SpacingBefore      = 30f;
            table.AddCell(cell);
            table.AddCell(new Phrase(new Chunk("Codigo", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12))));
            table.AddCell(new Phrase(new Chunk("Nombre Producto", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12))));
            table.AddCell(new Phrase(new Chunk("Cant. producida", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12))));
            table.AddCell(new Phrase(new Chunk("Cant. excedente", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12))));
            table.AddCell(dataGridView1.Rows[0].Cells[5].Value.ToString());
            table.AddCell(dataGridView1.Rows[0].Cells[4].Value.ToString());
            table.AddCell(dataGridView1.Rows[0].Cells[8].Value.ToString());
            table.AddCell(dataGridView1.Rows[0].Cells[9].Value.ToString());
            table.SetWidths(widths);
            doc.Add(table);
            #endregion

            #region Canvas de linea para firmas

            PdfPTable table3     = new PdfPTable(2);
            PdfPCell  cellFirmas = new PdfPCell();
            cellFirmas.Colspan             = 2;
            cellFirmas.HorizontalAlignment = 1;
            table3.SpacingBefore           = 20f;
            table3.SpacingAfter            = 20f;
            table3.LockedWidth             = true;
            table3.TotalWidth = 425f;


            var cell6   = new PdfPCell();
            var phrase8 = new Phrase();
            phrase8.Add(new Chunk("_________________", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12)));
            cell6.AddElement(phrase8);

            var cell7   = new PdfPCell();
            var phrase9 = new Phrase();
            phrase9.Add(new Chunk("Entrego conforme", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12)));
            cell7.AddElement(phrase9);

            var cell8    = new PdfPCell();
            var phrase10 = new Phrase();
            phrase10.Add(new Chunk("Recibo conforme", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12)));
            cell8.AddElement(phrase10);

            cellFirmas.Border = PdfPCell.NO_BORDER;
            cell6.Border      = PdfPCell.NO_BORDER;
            cell6.Border      = PdfPCell.NO_BORDER;
            cell7.Border      = PdfPCell.NO_BORDER;
            cell8.Border      = PdfPCell.NO_BORDER;
            table3.AddCell(cellFirmas);
            table3.AddCell(cell6);
            table3.AddCell(cell6);
            table3.AddCell(cell7);
            table3.AddCell(cell8);
            doc.Add(table3);
            #endregion

            #region Hora, fecha y Usuario
            var phrase11 = new Phrase();
            phrase11.Add(new Chunk("Fecha/Hora Impresion: ", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12)));
            phrase11.Add(new Chunk(DateTime.Now.ToString()));
            doc.Add(new Paragraph(phrase11));

            var phrase12 = new Phrase();
            phrase12.Add(new Chunk("Usuario: ", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12)));
            phrase12.Add(new Chunk(System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString()));
            doc.Add(new Paragraph(phrase12));
            #endregion


            doc.Close();
            writer.Close();
            System.Diagnostics.Process.Start(@"C:\Reporteria\ReporteGeneral.pdf");
            doc.CloseDocument();
        }