This is a migrated thread and some comments may be shown as answers.

RadBinaryImage - The provided binary data may not be valid image or may contains unknown header

5 Answers 193 Views
BinaryImage
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 2
Phil asked on 31 Aug 2010, 07:42 PM
Hi All:

I have loaded my db column declared as follows:
    [Thumbnail] [varbinary](max) NULL

I have loaded the column as follow:
Dim _pdfStream As FileStream = Nothing
Dim _fileName As String = "C:\Src\Proj\trunk\Data\2010-05-May-Cover.pdf"
If My.Computer.FileSystem.FileExists(_fileName) Then
    _pdfStream = New FileStream(_fileName, FileMode.Open, FileAccess.Read)
    Dim _length As Integer = CInt(_pdfStream.Length)
    Dim _contents(_length) As Byte
    _pdfStream.Read(_contents, 0, _length)
    _pdfStream.Close()
    ' ... insert _contents into db
End If

I reference as follows:
<asp:FormView
    id="mImageFormView" runat="server"
    DataSourceID="mImageDataSource">
    <ItemTemplate>
        <telerik:RadBinaryImage ID="rbiThumbnail" runat="server" Width="180px" Height="220px"
            DataValue='<%# Eval("Thumbnail") %>' AlternateText='No image'
            />
    </ItemTemplate>
</asp:FormView>

I am getting the following:
    The provided binary data may not be valid image or may contains unknown header

Anything wrong?
How do I verify that the image data is stored correctly?

Phil

5 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 01 Sep 2010, 11:44 AM
Phil,

I suspect that the error you are getting is due to the fact  that you are loading a pdf file. As you may know this is not among the control's supported types.

All the best,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Phil
Top achievements
Rank 2
answered on 01 Sep 2010, 01:13 PM
Hi:
Yes, I am loading PDF.  I was not aware that it was not a supported type.  I have also loaded a BMP.

What are the controls supported types?

Phil
0
Accepted
Rosen
Telerik team
answered on 01 Sep 2010, 02:36 PM
Hello Phil,

The supported types are the most popular image type bmp, jpeg, jpg, gif and png.

All the best,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
maurizio brusini
Top achievements
Rank 1
answered on 29 Dec 2010, 02:34 PM
AR u saying  Telerik dont  have a control that can view a pdf or text file ?????
so if i want use the telerik upload for text or pdf file in a raddgrid how can i view it?

maurizio
0
Phil
Top achievements
Rank 2
answered on 30 Dec 2010, 12:51 AM
Hi:
Lauch a new window. You read the pdf into a byte array, and replace the window with the pdf.  _oStream is a MemoryStream (you can replace with the byte array).  You can use an ashx handler.  This process is also useful for reporting services report, turned into pdf's.
Phil
Use http://converter.telerik.com/ to convert the following to C#.

Try
    Response.Clear()
    Response.Buffer = True
    Response.ContentType = "application/pdf"
    Response.BinaryWrite(_oStream.ToArray())
    HttpContext.Current.ApplicationInstance.CompleteRequest()
    ' Response.End()
Catch ex As System.Threading.ThreadAbortException
    ' Thread was being aborted.
    ' Response.End() is raising the above exception,
    ' but now moved to Page_Load, changed from Response.End()
    ' to CompleteRequest()
Catch ex As Exception
    DisplayErrorMessage(System.Reflection.MethodBase.GetCurrentMethod(), "ExportToPDF problem: " & ex.Message)
    Response.Write("<BR />")
    Response.Write(ex.Message)
Finally
    _oStream.Dispose()
End Try
Tags
BinaryImage
Asked by
Phil
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Phil
Top achievements
Rank 2
maurizio brusini
Top achievements
Rank 1
Share this question
or