I have the following Code that I need help with. I have several POs that I need to save to the hard drive in tif format. I can do one, but can't get multiple to work as a batch. I tried calling the print routine from another form, but the PO # won't change. Can anyone give me an ideal on how to do this? Using Local Report.
Imports Microsoft.Reporting.WebForms
Imports System.Data.SqlClient
Imports System
Imports System.Data
Imports System.Data.Odbc
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Microsoft.VisualBasic
Partial Class POSaveTif
Inherits System.Web.UI.Page
Dim PONumID As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim SessionVariable As String = Session("PONumID")
Dim rp As ReportParameter = New ReportParameter("PID", SessionVariable)
ReportViewer1.LocalReport.EnableExternalImages = True
ReportViewer1.LocalReport.SetParameters(New ReportParameter() {rp})
ReportViewer1.LocalReport.Refresh()
End Sub
Protected Sub Page_PreRenderComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRenderComplete
Dim PoNum As String = Session("PONumID")
Response.ContentType = "Image/tif"
Using local As New Microsoft.Reporting.WebForms.LocalReport
local.ReportPath = "PoPrint.rdlc"
Dim byts() As Byte = ReportViewer1.LocalReport.Render("Image", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
Using ms As New IO.MemoryStream(byts)
Using bmp As New Drawing.Bitmap(ms)
Dim FileName As String = "C:\" & PoNum & ".tif"
MsgBox(FileName)
bmp.Save(FileName, System.Drawing.Imaging.ImageFormat.Tiff)
End Using
End Using
End Using
Response.ClearContent()
Response.ClearHeaders()
Response.Flush()
Response.Close()
End Sub