none
Incluir titulo y comentarios al generar PDF con iTextSharp RRS feed

  • Pregunta

  • Hola

    Estoy generando un pdf con un gridview que me carga información de una DB, lo que busco es incluir Titulo y algunos comentarios antes de la tabla, lo estoy tratando de hacer de esta manera pero me incluye el titulo en la misma tabla y no se ve nada bien.

    Agradezco su ayuda...

       If GridView5.Rows.Count > 0 Then
                Dim columnsCount As Integer = GridView5.HeaderRow.Cells.Count
                Dim pdfTable As New PdfPTable(columnsCount)
                For Each headCell As TableCell In GridView5.HeaderRow.Cells
                    Dim font As New Font()
                    Dim pdfCell As New PdfPCell(New Phrase(headCell.Text, font))
                    pdfTable.AddCell(pdfCell)
                Next
                For Each gridView As GridViewRow In GridView5.Rows
                    For Each tableCell As TableCell In gridView.Cells
                        Dim font As New Font()
                        Dim pdfCell As New PdfPCell(New Phrase(tableCell.Text))
                        pdfTable.AddCell(pdfCell)
                    Next
                Next

                Dim pdfDocument As New Document(PageSize.A2, 20.0F, 20.0F, 20.0F, 20.0F)
                PdfWriter.GetInstance(pdfDocument, Response.OutputStream)
                pdfDocument.Open()
                Dim fecha As String = "Fecha de Reporte:" + DateTime.Now.ToString()
                Dim TITULO As New Chunk("BODEGA ", FontFactory.GetFont("ARIAL", 35, iTextSharp.text.Font.BOLD))
                pdfDocument.Add(New Paragraph(TITULO))
                pdfDocument.Add(New Paragraph("                       "))
                pdfDocument.Add(New Paragraph("                       "))
                pdfDocument.Add(New Paragraph("Inventario de libros "))
                pdfDocument.Add(New Paragraph(fecha))
                pdfDocument.Add(New Paragraph("                       "))
                pdfDocument.Add(pdfTable)
                pdfDocument.Add(New Paragraph("                       "))
                pdfDocument.AddCreationDate()
                pdfDocument.Add(New Paragraph("                       "))
                pdfDocument.Add(New Paragraph("                       "))
                pdfDocument.Add(New Paragraph("                       "))
                pdfDocument.Add(New Paragraph("_______________________", FontFactory.GetFont("ARIAL", 12, iTextSharp.text.Font.BOLD)))
                pdfDocument.Add(New Paragraph("Firma", FontFactory.GetFont("ARIAL", 12, iTextSharp.text.Font.BOLD)))
                pdfDocument.Close()
                pdfDocument.Close()
                Response.ContentType = "application/pdf"
                Response.AppendHeader("content-disposition", "attachment;filename=Reporte.pdf")
                Response.Write(pdfDocument)
                Response.Flush()
                Response.[End]()
            Else
            End If


    Respuesta de foro Microsoft

    martes, 14 de marzo de 2017 15:15