0

我有这个代码来拆分我在 Web 应用程序中使用的 pdf 文件。它适用于 1000 个页面,因为它在 1000 个页面被拆分后返回一个网页。但是我有包含 6000 页的 pdf,拆分 6000 页的 PDF 比拆分 1000 页的 PDF 需要更多时间。由于浏览器超时,我得到“网页不可用”。

我能做些什么来保持连接活跃?

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
4

0 回答 0