Exemple #1
0
        public string GenerarDetallePdf(List <DetalleFactura> detalleFacturas, string filename, Factura factura)
        {
            PDF documentoClientePdf = new PDF();

            try
            {
                documentoClientePdf.GuardarDetallesPdf(detalleFacturas, filename, factura);
                return("Se genró el Documento satisfactoriamente");
            }
            catch (Exception e)
            {
                return("Error al crear docuemnto" + e.Message);
            }
        }
Exemple #2
0
 public GuardarResponse(Factura factura)
 {
     Error   = false;
     Factura = factura;
 }
Exemple #3
0
        public void GuardarFactura(IList <Detalle> detalles, string ruta, Factura factura)
        {
            FileStream fs       = new FileStream(ruta, FileMode.Create);
            Document   document = new Document(iTextSharp.text.PageSize.LEGAL, 40, 40, 40, 40);
            PdfWriter  pw       = PdfWriter.GetInstance(document, fs);

            document.AddTitle("sarasoft");
            document.AddCreator("Proyecto Sarasoft");

            document.Open();
            DateTime fecha       = DateTime.Now;
            string   fechaactual = fecha.ToString();

            // Escribimos el encabezamiento en el documento
            document.Add(new Paragraph(fechaactual));
            document.Add(Chunk.NEWLINE);
            //margenes
            var content        = pw.DirectContent;
            var pageBorderRect = new Rectangle(document.PageSize);

            pageBorderRect.Left   += document.LeftMargin;
            pageBorderRect.Right  -= document.RightMargin;
            pageBorderRect.Top    -= document.TopMargin;
            pageBorderRect.Bottom += document.BottomMargin;

            content.SetColorStroke(BaseColor.BLACK);
            content.Rectangle(pageBorderRect.Left, pageBorderRect.Bottom, pageBorderRect.Width, pageBorderRect.Height);
            content.Stroke();
            //pie de pagina

            PdfPTable tabFot = new PdfPTable(new float[] { 1F });
            PdfPCell  cell;

            tabFot.TotalWidth = 50F;
            cell = new PdfPCell(new Phrase("Sarasoft", FontFactory.GetFont("ARIAL", 8, iTextSharp.text.Font.BOLD)));
            tabFot.AddCell(cell);
            tabFot.WriteSelectedRows(0, -1, 500, document.Bottom, pw.DirectContent);

            // logo
            string rutaimagen = @"C:\Users\AISM\Downloads\ProyectoTienda3 Díaz(5)\Resources\temp20190715-56303-ymuzcz.png";

            iTextSharp.text.Image imagen = iTextSharp.text.Image.GetInstance(rutaimagen);
            imagen.BorderWidth = 0;
            imagen.Alignment   = Element.ALIGN_CENTER;
            float percentage = 0.0f;

            percentage = 150 / imagen.Width;
            imagen.ScalePercent(percentage * 100);
            document.Add(imagen);

            Paragraph tienda = new Paragraph("SARASOFT\n");

            tienda.Alignment = Element.ALIGN_CENTER;
            document.Add(tienda);
            Paragraph asteriscos = new Paragraph("**********\n");

            asteriscos.Alignment = Element.ALIGN_CENTER;
            document.Add(asteriscos);
            Paragraph direccion = new Paragraph("Dir: Barrio El Cerro.Peñoncito, Bolívar\n");

            direccion.Alignment = Element.ALIGN_CENTER;
            document.Add(direccion);
            Paragraph telefono = new Paragraph("Tel: 3243454563\n");

            telefono.Alignment = Element.ALIGN_CENTER;
            document.Add(telefono);
            document.Add(new Paragraph("\n"));
            Paragraph detalle = new Paragraph("Factura de venta\n");

            detalle.Alignment = Element.ALIGN_CENTER;
            document.Add(detalle);

            Paragraph NoFact = new Paragraph("No fact:" + factura.Codigo + "\n");

            NoFact.Alignment = Element.ALIGN_CENTER;
            document.Add(NoFact);
            Paragraph fecha_ = new Paragraph("Fecha creacion:" + factura.Fecha + "\n");

            fecha_.Alignment = Element.ALIGN_CENTER;
            document.Add(fecha_);
            Paragraph fechaImpresion = new Paragraph("Fecha impresion:" + DateTime.Now.ToString() + "\n");

            fechaImpresion.Alignment = Element.ALIGN_CENTER;
            document.Add(fechaImpresion);
            document.Add(new Paragraph("\n"));


            //lo que dimos en clase
            document.Add(new Paragraph("                       Lista de Productos comprados", FontFactory.GetFont("ARIAL BLACK", 20, iTextSharp.text.Font.BOLD)));

            document.Add(new Paragraph("\n"));
            document.Add(LlenarTabla2(detalles));

            document.Add(new Paragraph("\n"));
            Paragraph totalPagar = new Paragraph("Total pagar:" + totalFactura + "\n");

            totalPagar.Alignment = Element.ALIGN_CENTER;
            document.Add(totalPagar);
            document.Add(new Paragraph("\n"));
            Paragraph saludo = new Paragraph("Gracias por preferirnos\n");

            saludo.Alignment = Element.ALIGN_CENTER;
            document.Add(saludo);

            document.Close();
        }