Help with Render

Last post 11-08-2009 10:34 PM by Zong-Qing Li - MSFT. 1 replies.

Sort Posts:

  • Help with Render

    11-04-2009, 9:17 PM
    • Member
      97 point Member
    • mhinkle2
    • Member since 01-18-2009, 3:56 AM
    • Posts 156

     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


     

  • Re: Help with Render

    11-08-2009, 10:34 PM
    Answer

    Hi,

    From your description, you always get the same PONumID when you execute that page with different PONumID. If so, please confirm whether those PONumIDs have been transferred into that page right. In addition, this issue may be caused by page cache, so I suggest using the following code to clear the page cache.

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Response.AppendHeader("Cache-Control", "no-store")
            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

     

     

    Please feel free to let me know if I’ve misunderstood anything.

    Sincerely,
    Zong-Qing Li
    Microsoft Online Community Support
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
Page 1 of 1 (2 items)