Tuesday, March 27, 2012

Embed a tif image in an RDLC

I need to expose a tif image as part of my report. Anyone know if
this is possible and if so how to do it?
Thanks,
JasonI didn't get an answer so I did the next best thing. I converted the
tiffs to gifs and replaced my result set:
Protected Sub butSubmit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles butSubmit.Click
' Get the table adapter
Dim exceptionAdapter As New
Automated_BillingTableAdapters.vw_GetExceptionsWithChargesTableAdapter
' Get the Table
Dim ExceptionTable As
Automated_Billing.vw_GetExceptionsWithChargesDataTable = _
exceptionAdapter.GetExceptionsByTypeandDate(ddlExceptionTypes.SelectedValue,
tbExceptioBegin.Text, tbExceptionEnd.Text)
' Start a new table to handle the results with the altered
image path
Dim NewExceptionTable As New
Automated_Billing.vw_GetExceptionsWithChargesDataTable
' Process the rows from the original table
For Each row As
Automated_Billing.vw_GetExceptionsWithChargesRow In ExceptionTable
' Get the original image path
Dim FilePath As String = row("ImagePath").ToString
' Check to see if file exists
If My.Computer.FileSystem.FileExists(FilePath) Then
' File exists
' Get the image
Dim imageFile As Image
imageFile = Image.FromFile(FilePath)
' Get the pages
Dim frameDimensions As FrameDimension = New
FrameDimension(imageFile.FrameDimensionsList(0))
Dim NumberOfFrames As Integer =imageFile.GetFrameCount(frameDimensions)
' Process the pages
For intFrame As Integer = 0 To NumberOfFrames - 1
imageFile.SelectActiveFrame(frameDimensions,
intFrame)
' Create a path for the new file for the page
Dim sPath As String
sPath = FilePath.Remove(FilePath.Length - 4, 4) &
"-" & intFrame.ToString() + ".gif"
' Check to see if the image already exists for the
page
If Not My.Computer.FileSystem.FileExists(sPath)
Then
' Image does not exist
' Create page image
Dim bmp As System.Drawing.Bitmap = New
System.Drawing.Bitmap(imageFile, 493, 639)
bmp.Save(sPath, ImageFormat.Gif)
bmp.Dispose()
End If
' Create a new row for the page
Dim NewRow As
Automated_Billing.vw_GetExceptionsWithChargesRow =NewExceptionTable.NewRow()
' Copy the orginal row info to the new row
NewRow.ChargeCode = row.ChargeCode
NewRow.ChargeCodeMod1 = row.ChargeCodeMod1
NewRow.ChargeCodeMod2 = row.ChargeCodeMod2
NewRow.ChargeID = row.ChargeID
NewRow.CodedDate = row.CodedDate
NewRow.Coder = row.Coder
NewRow.DxCode = row.DxCode
NewRow.DxID = row.DxID
NewRow.ExamDate = row.ExamDate
NewRow.ExceptionDate = row.ExceptionDate
NewRow.ExceptionType = row.ExceptionType
NewRow.ExceptionTypeID = row.ExceptionTypeID
NewRow.Patient = row.Patient
NewRow.PlaceOfService = row.PlaceOfService
NewRow.ReportID = row.ReportID
NewRow.ReportStatus = row.ReportStatus
NewExceptionTable.Rows.Add(NewRow)
' Set the new row's image path to the new file
NewRow.ImagePath = "file://" & sPath
Next
' Clean up
imageFile.Dispose()
End If
Next
' Replace the datasource for report viewer
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(New
Microsoft.Reporting.WebForms.ReportDataSource("Automated_Billing_vw_GetExceptionsWithCharges",
NewExceptionTable))
ReportViewer1.LocalReport.Refresh()
End Subsql

No comments:

Post a Comment