0

i have this code to generate pdf file with multiple pages.

Protected Sub GenerateReport()

    'pdf(creation)
    Dim document As New Document(PageSize.A4, 50.0F, 25.0F, 25.0F, 35.0F)
    Dim NormalFont As Font = FontFactory.GetFont("Times New Roman", 12)
    Using memoryStream As New System.IO.MemoryStream()
        Dim writer As PdfWriter = PdfWriter.GetInstance(document, memoryStream)
        Dim phrase As Phrase = Nothing
        Dim cell As PdfPCell = Nothing
        Dim table As PdfPTable = Nothing
        Dim para As Paragraph = Nothing
        Dim para1 As Paragraph = Nothing
        Dim footer As PdfPTable = Nothing
        ' Dim color__1 As Color = Nothing

        'open document
        document.Open()

        'open database connection
        obj1.getconn()
        obj1.cn.Open()

        'retrieve all datra of commondetailmaster   
        Dim da As New SqlDataAdapter("select * from commondetailmaster where email!='-' order by formno", obj1.cn)
        Dim ds As New DataSet
        da.Fill(ds)
        For i = 0 To 50
            'retriving common detail data

            Dim sanghname As String = ds.Tables(0).Rows(i)("sanghName").ToString
            Dim formno As String = ds.Tables(0).Rows(i)("formNo").ToString
            Dim familymember As String = ds.Tables(0).Rows(i)("totalFamilyPeople").ToString
            Dim yearlyincome As String = ds.Tables(0).Rows(i)("totalYearlyIncome").ToString
            'Dim Residenceaddress As String = ds.Tables(0).Rows(i)("ResidenceAddress").ToString
            Dim add() As String
            Dim count As Integer
            'add = Split(Residenceaddress, ",", 4)

            Dim da3 As New SqlDataAdapter("select * from address where formno='" & formno & "'", obj1.cn)
            Dim ds3 As New DataSet
            da3.Fill(ds3)
            Dim l As Integer
            For l = 0 To ds3.Tables(0).Rows.Count - 1
                Dim add1 As String = ds3.Tables(0).Rows(l)("add1").ToString
                Dim add2 As String = ds3.Tables(0).Rows(l)("add2").ToString
                Dim add3 As String = ds3.Tables(0).Rows(l)("add3").ToString
                Dim add4 As String = ds3.Tables(0).Rows(l)("add4").ToString

                Dim Samajname As String = ds.Tables(0).Rows(i)("SamajName").ToString
                Dim NativePlace As String = ds.Tables(0).Rows(i)("NativePlace").ToString
                Dim residencenumber As String = ds.Tables(0).Rows(i)("ResidenceContactNo").ToString
                Dim rno, rno2 As String
                If residencenumber.Length = 0 Then
                    rno = "-"
                    rno2 = "-"
                ElseIf residencenumber.Length = 10 Then
                    rno = residencenumber.Substring(0, 2)
                    rno2 = residencenumber.Substring(2, 8)
                Else
                    rno = "-"
                    rno2 = "-"
                End If


                'MsgBox(rno & "-" & rno2)
                Dim email As String = ds.Tables(0).Rows(i)("Email").ToString
                Dim workaddress As String = ds.Tables(0).Rows(i)("WorkAddress").ToString
                Dim otherdetail As String = ds.Tables(0).Rows(i)("OtherDetail").ToString

                Dim da1 As New SqlDataAdapter("select * from headoffamilydetail where formno='" & formno & "'", obj1.cn)
                Dim ds1 As New DataSet

                da1.Fill(ds1)
                For k = 0 To ds1.Tables(0).Rows.Count - 1
                    Dim headname As String = ds1.Tables(0).Rows(k)("headoffamilyfullname").ToString
                    Dim bloodgroup As String = ds1.Tables(0).Rows(k)("BloodGroup").ToString
                    Dim Dob As String = ds1.Tables(0).Rows(k)("Dob").ToString
                    Dim splitdob As String = Split(Dob.ToString, " ")(0)
                    Dim MaritalStatus As String = ds1.Tables(0).Rows(k)("MaritalStatus").ToString
                    Dim MobileNo As String = ds1.Tables(0).Rows(k)("MobileNo").ToString
                    Dim EducationQualification As String = ds1.Tables(0).Rows(k)("EducationalQualification").ToString
                    Dim ReligiousEducation As String = ds1.Tables(0).Rows(k)("ReligiousQualification").ToString
                    Dim ElectioncardNo As String = ds1.Tables(0).Rows(k)("ElectionCardNo").ToString


                    Dim da2 As New SqlDataAdapter("select * from MemberDetails where formno='" & formno & "'", obj1.cn)
                    Dim ds2 As New DataSet
                    da2.Fill(ds2)

                    document.NewPage()

                    para = New Paragraph("Samagra Jain Shwetambar Murtipujak Tapagachha Shree Mahasangh-Ahmedabad City", FontFactory.GetFont("Times New Roman", 12, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    para.Alignment = Element.ALIGN_CENTER
                    document.Add(para)

                    para = New Paragraph(sanghname, FontFactory.GetFont("Times New Roman", 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    para.Alignment = Element.ALIGN_CENTER
                    document.Add(para)

                    para = New Paragraph("Family Member Data Verification", FontFactory.GetFont("Times New Roman", 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    para.Alignment = Element.ALIGN_CENTER
                    document.Add(para)

                    para = New Paragraph("ID No: " & formno, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    para.Alignment = Element.ALIGN_LEFT
                    document.Add(para)

                    para = New Paragraph(headname, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    para.Alignment = Element.ALIGN_LEFT
                    document.Add(para)

                    para = New Paragraph(add1, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    para.Alignment = Element.ALIGN_LEFT
                    document.Add(para)

                    para = New Paragraph(add2, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    para.Alignment = Element.ALIGN_LEFT
                    document.Add(para)

                    para = New Paragraph(add3, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    para.Alignment = Element.ALIGN_LEFT
                    document.Add(para)

                    para = New Paragraph(add4, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    para.Alignment = Element.ALIGN_LEFT
                    document.Add(para)

                    'para = New Paragraph(add(0) & "," & add(1), FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    'para.Alignment = Element.ALIGN_LEFT
                    'document.Add(para)

                    'For count = 0 To add.Length - 1
                    '    para = New Paragraph(add(count), FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    '    para.Alignment = Element.ALIGN_LEFT
                    '    document.Add(para)
                    'Next

                    'para = New Paragraph(add(add.Length - 2) & "," & add(add.Length - 1), FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    'para.Alignment = Element.ALIGN_LEFT
                    'document.Add(para)



                    table = New PdfPTable(2)
                    table.TotalWidth = 400.0F
                    table.LockedWidth = True
                    table.SetWidths(New Single() {0.8F, 1.0F})
                    'table.DefaultCell.Border = 0
                    table.SpacingBefore = 20.0F
                    table.HorizontalAlignment = Element.ALIGN_LEFT

                    table.AddCell(PhraseCell(New Phrase("Family Member:", FontFactory.GetFont("Times New Roman", 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase(familymember, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Residence Number:", FontFactory.GetFont("Times New Roman", 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase(rno & "-" & rno2, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Total Yearly Income:", FontFactory.GetFont("Times New Roman", 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase(yearlyincome, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Samaj Name:", FontFactory.GetFont("Times New Roman", 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase(Samajname, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Native Place:", FontFactory.GetFont("Times New Roman", 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase(NativePlace, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Email:", FontFactory.GetFont("Times New Roman", 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase(email, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                    document.Add(table)

                    table = New PdfPTable(6)
                    table.TotalWidth = 500.0F
                    table.LockedWidth = True
                    'table.SetWidths(New Single() {0.3F, 1.0F})
                    'table.DefaultCell.Border = 0
                    table.SpacingBefore = 20.0F
                    table.HorizontalAlignment = Element.ALIGN_LEFT

                    table.AddCell(PhraseCell(New Phrase("  ", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_CENTER))
                    table.AddCell(PhraseCell(New Phrase("1", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_CENTER))
                    table.AddCell(PhraseCell(New Phrase("2", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_CENTER))
                    table.AddCell(PhraseCell(New Phrase("3", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_CENTER))
                    table.AddCell(PhraseCell(New Phrase("4", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_CENTER))
                    table.AddCell(PhraseCell(New Phrase("5", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_CENTER))

                    table.AddCell(PhraseCell(New Phrase("Member Name:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Relation With Head", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Date of Birth:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Blood Group:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Marital Status:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Educational Qualification:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    'table.AddCell(PhraseCell(New Phrase("Religious Education:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    'table.AddCell(PhraseCell(New Phrase("Election Card No", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    'table.AddCell(PhraseCell(New Phrase("Mobile No.", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    'table.AddCell(PhraseCell(New Phrase("Business:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))

                    For j = 0 To ds2.Tables(0).Rows.Count - 1
                        table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("Fullname").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                        table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("RelationWithHOD").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                        table.AddCell(PhraseCell(New Phrase(Split(ds2.Tables(0).Rows(j)("DOB").ToString, " ")(0), FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                        table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("BloodGroup").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                        table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("MaritalStatus").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                        table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("EducationalQualification").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                        'table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("ReligiousEducation").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                        'table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("ElectioncardNo").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                        'table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("MobileNo").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                        'table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("Business").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                    Next
                    document.Add(table)

                    table = New PdfPTable(5)
                    table.TotalWidth = 500.0F
                    table.LockedWidth = True
                    'table.SetWidths(New Single() {0.3F, 1.0F})
                    'table.DefaultCell.Border = 0
                    table.SpacingBefore = 20.0F
                    table.HorizontalAlignment = Element.ALIGN_LEFT

                    table.AddCell(PhraseCell(New Phrase(" ", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_CENTER))
                    table.AddCell(PhraseCell(New Phrase("6", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_CENTER))
                    table.AddCell(PhraseCell(New Phrase("7", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_CENTER))
                    table.AddCell(PhraseCell(New Phrase("8", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_CENTER))
                    table.AddCell(PhraseCell(New Phrase("9", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_CENTER))
                    'table.AddCell(PhraseCell(New Phrase("5.", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_CENTER))

                    table.AddCell(PhraseCell(New Phrase("Member Name:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    'table.AddCell(PhraseCell(New Phrase("Relation With Head", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                    'table.AddCell(PhraseCell(New Phrase("Date of Birth:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                    'table.AddCell(PhraseCell(New Phrase("Blood Group:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                    'table.AddCell(PhraseCell(New Phrase("Marital Status:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                    'table.AddCell(PhraseCell(New Phrase("Educational Qualification:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Religious Education:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Election Card No", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Mobile No.", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                    table.AddCell(PhraseCell(New Phrase("Business:", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))

                    For j = 0 To ds2.Tables(0).Rows.Count - 1
                        table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("Fullname").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                        'table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("RelationWithHOD").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                        'table.AddCell(PhraseCell(New Phrase(Split(ds2.Tables(0).Rows(j)("DOB").ToString, " ")(0), FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                        'table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("BloodGroup").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                        'table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("MaritalStatus").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                        'table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("EducationalQualification").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT))
                        table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("ReligiousEducation").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                        table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("ElectioncardNo").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                        table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("MobileNo").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                        table.AddCell(PhraseCell(New Phrase(ds2.Tables(0).Rows(j)("Business").ToString, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD)), PdfPCell.ALIGN_LEFT))
                    Next
                    document.Add(table)

                    para = New Paragraph(" ", FontFactory.GetFont("Times New Roman", 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    para.Alignment = Element.ALIGN_LEFT
                    document.Add(para)

                    para = New Paragraph("  ", FontFactory.GetFont("Times New Roman", 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    para.Alignment = Element.ALIGN_LEFT
                    document.Add(para)

                    para = New Paragraph("Other Detail:", FontFactory.GetFont("Times New Roman", 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    para.Alignment = Element.ALIGN_LEFT
                    document.Add(para)

                    para = New Paragraph(otherdetail, FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    para.Alignment = Element.ALIGN_LEFT
                    document.Add(para)


                    'para.SpacingBefore = 500.0F
                    'para = New Paragraph("[Note: If Any Modifications or Addition or Deletion in Above Data Kindly Mail us on mahasanghahmedabad@gmail.com] ", FontFactory.GetFont("Times New Roman", 16, iTextSharp.text.Font.BOLD, BaseColor.BLACK))
                    'para.Alignment = Element.ALIGN_CENTER
                    'document.Add(para)

                    footer = New PdfPTable(1)
                    footer.TotalWidth = 1000.0F
                    footer.LockedWidth = True
                    cell = New PdfPCell(New Phrase("[ Note: If Any Modifications or Addition or Deletion in Above Data Kindly Mail us on mahasangh.ahmedabad@gmail.com ", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)))
                    footer.DefaultCell.Border = 0
                    cell.Border = 0
                    footer.AddCell(cell)
                    cell = New PdfPCell(New Phrase("            Or Modify Data in Above Letter and Drop/Post it at NAVRANGPURA JAIN SANGH Office ] ", FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK)))
                    footer.DefaultCell.Border = 0
                    cell.Border = 0
                    footer.AddCell(cell)

                    cell = New PdfPCell(New Phrase(" © Nishi Infotech", FontFactory.GetFont("Times New Roman", 8, BaseColor.GRAY)))
                    footer.DefaultCell.Border = 0
                    cell.Border = 0
                    cell.HorizontalAlignment = Element.ALIGN_CENTER
                    footer.AddCell(cell)

                    footer.WriteSelectedRows(0, -1, 25, 60, writer.DirectContent)
                    'document.Close()
                    'Dim bytes As Byte() = memoryStream.ToArray()
                    ''File(memoryStream.GetBuffer(), "application/pdf", "member.pdf")
                    'memoryStream.Close()
                    'HttpContext.Current.Response.Clear()
                    'HttpContext.Current.Response.ContentType = "application/pdf"
                    'HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename='" & formno & "'.pdf")
                    '' HttpContext.Current.Response.ContentType = "application/pdf"
                    'HttpContext.Current.Response.Buffer = True
                    'HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache)
                    'HttpContext.Current.Response.BinaryWrite(bytes)

                    'HttpContext.Current.Response.[End]()
                    'HttpContext.Current.Response.Close()

                Next

            Next



        Next

        document.Close()
        Dim bytes As Byte() = memoryStream.ToArray()
        'File(memoryStream.GetBuffer(), "application/pdf", "member.pdf")
        memoryStream.Close()
        HttpContext.Current.Response.Clear()
        HttpContext.Current.Response.ContentType = "application/pdf"
        HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=memberdetails.pdf")
        ' HttpContext.Current.Response.ContentType = "application/pdf"
        HttpContext.Current.Response.Buffer = True
        HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache)
        HttpContext.Current.Response.BinaryWrite(bytes)

        HttpContext.Current.Response.[End]()
        HttpContext.Current.Response.Close()

    End Using

This code is perfectly working to generate pdf it contains all pages in one pdf but i want to mail single page to single user.please help me to solve this problem!thanks in Advance

  • There is no code in there to email anything. Show what you have tried so far. There isn't much point posting working code. We need to see code that isn't working. – Matt Wilko Sep 16 '14 at 09:09
  • can you please suggest me vb.net code to split pdf file by pages to individual files. – user2959550 Sep 16 '14 at 09:22

0 Answers0