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