0

I Have this code to split pdf file that I am using in a web application. It works fine for 1000 pages in the sense that it returns a web page after 1000 pages are split. But I have pdf containing 6000 pages and it takes more time to split a PDF with 6000 pages than it takes to split a PDF with 1000 pages. Due to the browser time-out, I get "Web Page Not Available".

What can I do to keep the connection alive?

Public Sub splitandsave(ByVal inputpath As String, ByVal outputpath As String)
    obj1.getconn()
    obj1.cn.Open()

    Dim file As FileInfo = New FileInfo(inputpath)
    Dim name As String = file.Name.Substring(0, file.Name.LastIndexOf("."))
    Using reader As PdfReader = New PdfReader(inputpath)

        Dim pagenumber As Integer
        For pagenumber = 1 To reader.NumberOfPages
            Dim email As String
            Dim da As New SqlDataAdapter("select * from commondetailmaster where email!='-' order by formno", obj1.cn)
            Dim ds As New DataSet
            da.Fill(ds)
            email = ds.Tables(0).Rows(pagenumber)("formNo").ToString
            Dim quota1 As String
            quota1 = "'"
            Dim filename As String = quota1 & email.ToString() & quota1 & ".pdf"
            Dim document As Document = New Document()
            Dim copy As PdfCopy = New PdfCopy(document, New FileStream(outputpath & "\\" & filename, FileMode.Create))
            document.Open()
            copy.AddPage(copy.GetImportedPage(reader, pagenumber))
            document.Close()
        Next
    End Using

End Sub
Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • 1
    What happens in case of that *pdf containing 6000 pages*? – mkl Sep 19 '14 at 10:35
  • I don't get it. If it works for 1000, why not 6000? What is the specific problem? – Adam Sep 19 '14 at 13:42
  • It shows Webpage Not Available.And When I Keep Breakpoint Process Not debugging – user2959550 Sep 20 '14 at 05:15
  • Apparently, you have never heard of the concept "browser timeout" and you don't know how to keep a connection alive in case a server process takes too long. This is not a question for an iText expert. This is a question for a web developer. Ask a web developer! I have adapted your question. – Bruno Lowagie Sep 20 '14 at 09:49

0 Answers0