private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < listaVacia.Count; i++)
                {

                    ProductoPDF ppdf = new ProductoPDF(((Producto)listaVacia[i]).Detalle, ((Producto)listaVacia[i]).Total);
                    listaPDF.Add(ppdf);
                }

                bdd_pdf.DataSource = listaPDF;
                bdd_pdf.Refresh();

                ArrayList titulos = new ArrayList();

                DataTable datosTabla = new DataTable();

                //Especificar ruta del archivo con extensión de WORD.

                OtrosFormatos OF = new OtrosFormatos(Application.StartupPath + "test.doc");

                //obtenemos los titulos del grid y creamos las columnas de la tabla

                foreach (DataGridViewColumn item in bdd_pdf.Columns)
                {

                    titulos.Add(item.HeaderText);

                    datosTabla.Columns.Add();

                }

                //se crean los renglones de la tabla

                foreach (DataGridViewRow item in bdd_pdf.Rows)
                {

                    DataRow rowx = datosTabla.NewRow();

                    datosTabla.Rows.Add(rowx);

                }

                //se pasan los datos del dataGridView a la tabla

                foreach (DataGridViewColumn item in bdd_pdf.Columns)
                {

                    foreach (DataGridViewRow itemx in bdd_pdf.Rows)
                    {

                        datosTabla.Rows[itemx.Index][item.Index] =

                        bdd_pdf[item.Index, itemx.Index].Value;

                    }

                }

                OF.Export(titulos, datosTabla);

                Process.Start(OF.xpath);

            }

            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);

            }
            Principal.cerrar_ventana_producto_admin = false;
            this.Close();
        }
        private void btn_a_pdf_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < listaVacia.Count; i++)
            {

                ProductoPDF ppdf = new ProductoPDF(((Producto)listaVacia[i]).Detalle, ((Producto)listaVacia[i]).Total);
                listaPDF.Add(ppdf);
            }
            bdd_pdf.DataSource = listaPDF;
            try
            {

                Document doc = new Document(PageSize.A4.Rotate(), 10, 10

                , 10, 10);

                string filename = "DataGridViewTest.pdf";

                FileStream file = new FileStream(filename,

                FileMode.OpenOrCreate,

                FileAccess.ReadWrite,

                FileShare.ReadWrite);

                PdfWriter.GetInstance(doc, file);

                doc.Open();

                GenerarDocumento(doc);

                doc.Close();

                Process.Start(filename);

            }

            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);

            }
        }