private string crearPdf() { List <claseMedicamento> lista = new List <claseMedicamento>(); lista = cnx.medicamentosStockBajo(); PdfPTable pdfTable = new PdfPTable(lista.Count); pdfTable.DefaultCell.Padding = 3; pdfTable.WidthPercentage = 80; pdfTable.HorizontalAlignment = Element.ALIGN_CENTER; pdfTable.DefaultCell.BorderWidth = 1; pdfTable.AddCell("Nombre"); pdfTable.AddCell("Cantidad necesaria"); //Recorrrer el arrayList donde estan los medicamentos que tienen el stockactual //Por debajo del stock minimo for (int i = 0; i < lista.Count; i++) { pdfTable.AddCell(lista[i].Nombre); pdfTable.AddCell(Convert.ToString(lista[i].Stockminimo - lista[i].Stockactual)); } pdfTable.AddCell(DateTime.Now.ToString("MM-dd-yy")); string folderPath = "C:\\ticket\\"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string nombreTicket = DateTime.Now.ToString("MM-dd-yy_HH-mm-ss") + ".pdf"; folderPath += nombreTicket; using (FileStream stream = new FileStream(folderPath, FileMode.Create)) { Document pdfDoc = new Document(PageSize.A6, 10f, 10f, 10f, 0f); PdfWriter.GetInstance(pdfDoc, stream); pdfDoc.Open(); pdfDoc.Add(pdfTable); pdfDoc.Close(); stream.Close(); } Process pc = new Process(); pc.StartInfo.FileName = folderPath; pc.Start(); return(folderPath); }