Dim cmd As New SQLCommand
cmd.C
cmd.CommandText="select 訂單號 from 國內訂單總表 where 訂單號>='" & e.Form.Controls("txt_dh1").text & "' And 訂單號<='" & e.Form.Controls("txt_dh2").text & "' group by 訂單號 order by 訂單號"
Dim dt As DataTable = cmd.executereader
Dim file As String = e.Form.Controls("TextBox1").text
Dim Test As pdfSharp.pdf.PdfDocument = pdfSharp.pdf.IO.PdfReader.Open(file,pdfSharp.pdf.IO.PdfDocumentOpenMode.Import) '读取Test1.pdf
Dim name As String = System.IO.Path.GetFileNameWithoutExtension(file)
For i As Integer = 0 To Test.PageCount - 1
Dim dr As DataRow = dt.datarows(i)
Dim outputDocument As pdfSharp.pdf.PdfDocument = new pdfSharp.pdf.PdfDocument()
outputDocument.Version = Test.Version
outputDocument.Info.Title = String.Format("Page {0} of {1}", i + 1, Test.Info.Title)
outputDocument.Info.Creator = Test.Info.Creator
outputDocument.AddPage(Test.Pages(i))
outputDocument.Save(String.Format(ProjectPath & dr("訂單號") & ".pdf", name, i + 1))
Next