Why am I struggling so much with Itextsharp.??
  
I can generate images with itextsharp and all other stufff, what I'm struggling 
with is structuring a pdf layout,
I can create a header, side image, footer image and I can print to 
the pdf document, but I can't get it to be more structured and appear 
without any outlines/flows of the table...and I want to limit a few rows on a 
page to be displayed,
Here is my full vb code:
 Public Sub GeneratePDF()
        Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 10.0F)
        pdfDoc.AddCreationDate()
        'PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
        pdfDoc.Open()
        Using stream As New MemoryStream()
            Dim sw As New StringWriter()
            Dim hTextWriter As New HtmlTextWriter(sw)

            'GridView2.RenderControl(hTextWriter)
            Dim sr As New StringReader(sw.ToString())
            Dim htmlparser As New HTMLWorker(pdfDoc)
            Dim writer As PdfWriter = PdfWriter.GetInstance(pdfDoc, stream)
       
            Dim CoverPath As String = (Server.MapPath("images/PDF-PageCover 
Concept-1.jpg"))
            Dim HeaderImage As String = (Server.MapPath("images/PDF-Header 
Concept-2a.jpg"))
            Dim SideBarImage As String = (Server.MapPath("images/PDF-Sidebar 
Concept-2b.jpg"))
            Dim BottomImage As String = 
(Server.MapPath("images/PDF-FooterConcept-2c.jpg"))
            pdfDoc.Open()
            txtCurrentDate.Text = time.ToString(format)
            htmlparser.Parse(sr)
            writer.CloseStream = False

            Dim table As New PdfPTable(1)
            table.TotalWidth = 450.0F
            table.LockedWidth = True
            'table.TotalHeight = 216.0F
            'table.Rows.

            Dim header As New PdfPCell(New Phrase(" "))
            header.Colspan = 3
            header.Border = 0
            table.AddCell(header)
            table.HorizontalAlignment = Element.ALIGN_RIGHT
          
            
            Using conn As New SqlConnection(connnecxion)
                Dim query As String = "select * from Results table "

                Dim cmd As New SqlCommand(query, conn)
                Dim dt As New DataTable()
                Dim sqlDa As New SqlDataAdapter(cmd)
                cmd.Parameters.AddWithValue("@User_ID", 
Request.QueryString("UserID"))
                sqlDa.Fill(dt)
                Try
                    conn.Open()
                    If dt.Rows.Count > 0 Then
                        table.AddCell(dt(0)("Result ").ToString())  'Result is 
the name of the column i want to retrieve
                        table.AddCell(dt(1)("Result ").ToString())
                        table.AddCell(dt(3)("Result ").ToString())
                        table.AddCell(dt(4)("Result ").ToString())
                        table.AddCell(dt(5)("Result ").ToString())
                        table.AddCell(dt(6)("Result ").ToString())
                        table.AddCell(dt(7)("Result ").ToString())
                        table.AddCell(dt(8)("Result ").ToString())
                        table.AddCell(dt(9)("Result ").ToString())
                        table.AddCell(dt(10)("Result ").ToString())
                        table.AddCell(dt(11)("Result ").ToString())
                        table.AddCell(dt(12)("Result ").ToString())
                        table.AddCell(dt(13)("Result ").ToString())
                        table.AddCell(dt(14)("Result ").ToString())
                        table.AddCell(dt(15)("Result ").ToString())
                    End If

                Catch ex As Exception
                    Response.Write(ex.Message)
                End Try

                Dim coverpdf As Global.iTextSharp.text.Image = 
Global.iTextSharp.text.Image.GetInstance(CoverPath)
                coverpdf.ScaleAbsolute(574, 822)
                pdfDoc.Add(coverpdf)

                Dim Headerpdf As Global.iTextSharp.text.Image = 
Global.iTextSharp.text.Image.GetInstance(HeaderImage)
                ' Headerpdf.BorderWidth = 0.0F
                Headerpdf.ScaleAbsolute(574, 120)
                Headerpdf.Alignment = Global.iTextSharp.text.Image.ALIGN_TOP
                Headerpdf.SetAbsolutePosition(12, 705)


                Dim sidepdf As Global.iTextSharp.text.Image = 
Global.iTextSharp.text.Image.GetInstance(SideBarImage)
                sidepdf.SetAbsolutePosition(10.5, 71)
                'sidepdf.IndentationRight = 500.0F
                'sidepdf.IndentationLeft = -90.0F
                sidepdf.ScaleAbsolute(125, 640)


                Dim Footerpdf As Global.iTextSharp.text.Image = 
Global.iTextSharp.text.Image.GetInstance(BottomImage)
                Footerpdf.ScaleToFit(90.0F, 200.0F)
                ' Footerpdf.BorderWidth = 10.0F
                Footerpdf.ScalePercent(24.5F)
                ' Footerpdf.SetAbsolutePosition(pdfDoc.PageSize.Width - 395.5F 
- 200.5F,
                ' pdfDoc.PageSize.Height - 768.0F - 72.0F)
                Footerpdf.Alignment = Global.iTextSharp.text.Image.ALIGN_BOTTOM
                Footerpdf.SetAbsolutePosition(10.5, 0)
                

                ' For i As Integer = 2 To 8
                ' Convert.ToString(Headerpdf)
                ' pdfDoc.Add(sidepdf)
                ' pdfDoc.Add(Headerpdf)
                ' pdfDoc.Add(table)
                ' pdfDoc.Add(Footerpdf)
                ' Next

                For i As Integer = 0 To 4 - 2  'I want my pdf pages to 
be created according to the results returned by the sql query, and at 
the same time, each page must have it's own Headerimage, sideimage, 
footerimage
                    pdfDoc.Add(sidepdf)                                       
                    pdfDoc.Add(Headerpdf)                     
                    pdfDoc.Add(table)                    
                    pdfDoc.Add(Footerpdf)
                Next

            End Using
            pdfDoc.Close()
            stream.Position = 0
            Response.ContentType = "pdf/application"
            Response.AddHeader("content-disposition", 
"attachment;filename=Results.pdf")
            Response.OutputStream.Write(stream.GetBuffer(), 0, 
stream.GetBuffer().Length)
        End Using
    End Sub
and I want to align my table center of the page
There is my code above guys, please tell me what I'm missing???
------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to