protected void Button1_Click(object sender, EventArgs e)
        {
            if (lblInforme.Text != "")
            {
                if (txtFechaInicio.Text != "" && txtFechaTermino.Text != "")
                {
                    string[] str  = txtFechaInicio.Text.Split('/');
                    DateTime f1   = Convert.ToDateTime(str[2] + "-" + str[1] + "-" + str[0] + " 00:00:00");
                    string[] str2 = txtFechaTermino.Text.Split('/');
                    DateTime f2   = Convert.ToDateTime(str2[2] + "-" + str2[1] + "-" + str2[0] + " 23:59:59");
                    if (ddlSeccion.SelectedValue.ToString() == "Todas")
                    {
                        if (ddlMaquinas.SelectedValue.ToString() != "Seleccione...")
                        {
                            lblInforme.Text = sc.Carga_Programacion_PDF("", ddlMaquinas.SelectedValue.ToString(), f1, f2, 2);
                        }
                        else
                        {
                            lblInforme.Text = sc.Carga_Programacion_PDF("", "", f1, f2, 1);
                        }
                    }
                    else
                    {
                        if (ddlSeccion.SelectedValue.ToString() == "Rotativa")
                        {
                            if (ddlMaquinas.SelectedValue.ToString() != "Seleccione...")
                            {
                                lblInforme.Text = sc.Carga_Programacion_PDF("", ddlMaquinas.SelectedValue.ToString(), f1, f2, 4);
                            }
                            else
                            {
                                lblInforme.Text = sc.Carga_Programacion("", "", f1, f2, 3);
                            }
                        }
                        else if (ddlSeccion.SelectedValue.ToString() == "Planas")
                        {
                            if (ddlMaquinas.SelectedValue.ToString() != "Seleccione...")
                            {
                                lblInforme.Text = sc.Carga_Programacion_PDF("", ddlMaquinas.SelectedValue.ToString(), f1, f2, 6);
                            }
                            else
                            {
                                lblInforme.Text = sc.Carga_Programacion_PDF("", "", f1, f2, 5);
                            }
                        }
                    }
                }
                else
                {
                    string[] str = DateTime.Now.ToString("dd/MM/yyyy").Split('/');
                    DateTime f1  = Convert.ToDateTime(str[2] + "-" + str[1] + "-" + str[0] + " 00:00:00");
                    DateTime f2  = Convert.ToDateTime(str[2] + "-" + str[1] + "-" + str[0] + " 23:59:59");

                    if (ddlSeccion.SelectedValue.ToString() == "Todas")
                    {
                        lblInforme.Text = sc.Carga_Programacion_PDF("", "", f1, f2, 1);
                    }
                    else
                    {
                        if (ddlSeccion.SelectedValue.ToString() == "Rotativa")
                        {
                            if (ddlMaquinas.SelectedValue.ToString() != "Seleccione...")
                            {
                                lblInforme.Text = sc.Carga_Programacion_PDF("", ddlMaquinas.SelectedValue.ToString(), f1, f2, 4);
                            }
                            else
                            {
                                lblInforme.Text = sc.Carga_Programacion_PDF("", "", f1, f2, 3);
                            }
                        }
                        else if (ddlSeccion.SelectedValue.ToString() == "Planas")
                        {
                            if (ddlMaquinas.SelectedValue.ToString() != "Seleccione...")
                            {
                                lblInforme.Text = sc.Carga_Programacion_PDF("", ddlMaquinas.SelectedValue.ToString(), f1, f2, 6);
                            }
                            else
                            {
                                lblInforme.Text = sc.Carga_Programacion_PDF("", "", f1, f2, 5);
                            }
                        }
                    }
                }



                Document document = new Document();
                document.SetPageSize(PageSize.A4.Rotate());
                PdfWriter.GetInstance(document, new FileStream(Request.PhysicalApplicationPath + "\\MySamplePDF.pdf", FileMode.Create));
                document.Open();
                iTextSharp.text.html.simpleparser.HTMLWorker hw =
                    new iTextSharp.text.html.simpleparser.HTMLWorker(document);
                hw.Parse(new StringReader("<div align='center'><h1>Programacion de Producción</h1></div>&nbsp;" + lblInforme.Text));


                HeaderFooter header = new HeaderFooter(new Paragraph("Header\n <div style='color:red;'>apekedikdjaj</div>"), false);
                document.Header = header;


                document.Close();

                Response.Clear();
                Response.ContentType = "application/pdf";
                Response.AddHeader("Content-Disposition", "attachment; filename=MySamplePDF");
                Response.WriteFile(Request.PhysicalApplicationPath + "\\MySamplePDF.pdf");
                Response.End();
            }
        }