Dim nnn As String = "ใบค่าประกันและค่ามัดจำ ห้อง"
Dim output = New MemoryStream()
Dim bf As BaseFont = BaseFont.CreateFont("c:\Windows\fonts\Tahoma.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED)
Dim document As New Document(PageSize.A6, 10, 10, 14, 14)
Dim writer As PdfWriter = PdfWriter.GetInstance(document, output)
Dim f As New Font(bf, 8.0F, Font.NORMAL)
' Open the document to enable you to write to the document
document.Open()
'======================================Variable=====================================
Dim tt, calpriceR, caldep, caldadep As Integer
Dim headerRoomID As New PdfPCell(New Phrase("ห้องพักหมายเลข" + " " + DropDownList1.SelectedItem.Text, f))
headerRoomID.Colspan = 2
Dim headerName As New PdfPCell(New Phrase((memTNLN), f))
headerName.Colspan = 2
Dim listPay As New PdfPCell(New Phrase("รายการ", f))
Dim pricePay As New PdfPCell(New Phrase("จำนวนเงิน", f))
Dim priceRoomN As New PdfPCell(New Phrase("ค่าห้องพัก", f))
Dim priceRoomB As New PdfPCell(New Phrase((amount_room.Text), f))
Dim mudJamN As New PdfPCell(New Phrase("ค่ามัดจำ", f))
Dim mudJam As New PdfPCell(New Phrase((amount_mount_money0.Text), f))
Dim guaranteeN As New PdfPCell(New Phrase("ค่าประกันความเสียหาย", f))
Dim guarantee As New PdfPCell(New Phrase((guarantee_money.Text), f))
Dim totalN As New PdfPCell(New Phrase("รวม", f))
'==============Cal Total=============
calpriceR = Convert.ToInt64(amount_room.Text)
caldep = Convert.ToInt64(amount_mount_money0.Text)
caldadep = Convert.ToInt64(guarantee_money.Text)
tt = calpriceR + caldep + caldadep
Dim total As New PdfPCell(New Phrase((tt), f))
table.AddCell(headerRoomID)
table.AddCell(headerName)
table.AddCell(listPay)
table.AddCell(pricePay)
table.AddCell(priceRoomN)
table.AddCell(priceRoomB)
table.AddCell(mudJamN)
table.AddCell(mudJam)
table.AddCell(guaranteeN)
table.AddCell(guarantee)
table.AddCell(totalN)
table.AddCell(total)
document.Add(table)
document.Add(New Paragraph(" " + "ลงชื่อผู้รับเงิน" + " " + "........................................", f))
'===================Close Pdf=================
document.Close()
Response.ContentType = "application/pdf"
Response.AddHeader("Content-Disposition", String.Format("attachment;filename=Receipt-{0}.pdf", nnn))
Response.BinaryWrite(output.ToArray())
Response.OutputStream.Write(output.GetBuffer(), 0, output.GetBuffer().Length)
Response.Redirect("SearchEditRent.aspx") ' ปัญหาอยู่ที่บรรทัดนี้ค่ะ
ถ้าใส่ Response.Redirect("SearchEditRent.aspx") มันจะไม่แสดงไฟล์ PDF ค่ะ แต่จะเปลี่ยนไปที่ หน้า SearchEditRent.aspx เลย
จุดประสงค์คือ อยากให้แสดงไฟล์ PDF ก่อน แล้วค่อยเปลี่ยนไปที่หน้า SearchEditRent.aspx ค่ะ