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

6 posts, 1 answers
  1. Phil
    Phil avatar
    273 posts
    Member since:
    Jul 2008

    Posted 31 Aug 2010 Link to this post

    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
  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 01 Sep 2010 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Phil
    Phil avatar
    273 posts
    Member since:
    Jul 2008

    Posted 01 Sep 2010 Link to this post

    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
  5. Answer
    Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 01 Sep 2010 Link to this post

    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
  6. maurizio brusini
    maurizio brusini avatar
    10 posts
    Member since:
    Oct 2009

    Posted 29 Dec 2010 Link to this post

    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
  7. Phil
    Phil avatar
    273 posts
    Member since:
    Jul 2008

    Posted 29 Dec 2010 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017