Tag Archives: Chart

[RESOLVED] display the bitmap image


Dear all,

i had drawed a graph by clicking a analyze button, however when i click it, it will go to a new screen. below is my coding:

Response.ContentType = "image/gif"
 

        objBitmap.Save(Response.OutputStream, ImageFormat.Gif)




below is the condition i want, when i click the button Analyze, the image (graph) is showed under the button with the header and template:

 

my current condition is when i click the button analyze, it will totaly display the graph only without the header and template as print screen below:


 


how to change the coding to let the template and heaser showed together with the bar chart?


hope can get reply from any of you. i am using vb.net

thanks in advanced.

you can drow images in a separate page. and put one image control in your current page.

 when button click event you can change  imagecontrol image url to previously mentioned page.

button_click()
{
image1.imageurl="pageIsUsingToDisplayImage.aspx?imageId=someIdofimage";
}

if you want ot know more about handing image check this link

http://www.codeproject.com/Articles/126421/Image-Handling-In-ASP-NET.aspx

[RESOLVED] Image is disappear when I call web page by asp.net web form URL routing

My web page is having an asp.net chart control. It’s generating fine for normal view.

When I try to access same page using asp.net web forms URL routing even the chart is generated it wont appear.

 

This is the working URL of browser

 

url

http://localhost:60316/control/CataloguePageStatic.aspx

 

<br />
<img id="MainContent_ChartStatPageView" src="/control/ChartImg.axd?i=chart_bdbc69194ab84888b1b2102d1712af8f_0.png&amp;g=e0446e41d13f46dab74bb0873cdc9cee" alt="" style="height:300px;width:656px;border-width:0px;" />
<br />

 

This is the not working URL of the browser 

url

http://localhost:60316/control/myretailers/abc/manage/catalogues/stat/7da651c4-13d3-499b-a11b-f6baa4f4c7df

 

generated image source 
 
<img id="MainContent_ChartStatPageView" src="/control/myretailers/abc/manage/catalogues/stat/ChartImg.axd?i=chart_55636b86c8ce4a3eba2c29cd874e6737_6.png&amp;g=f0eb41381c3d4f1d8fa7dbc7d6f6d476" alt="" style="height:300px;width:656px;border-width:0px;" />
<br />

 

 

Please provide me guide to resolve this issue 

Set the image Url as shown like this...

http://www.codeproject.com/KB/aspnet/asp_net4_0_URLRouting.aspx

Thanks,

[RESOLVED] IFrame wont display MS Chart of WebPage

I am trying to display a web page on the server that has a MS Chart in it using and IFrame. It renders the page except the Chart. it show the box of the chart with a red X in it. No errors. However if i set the url to a link button it works fine or if i paste the url in IE it works fine. Any ideas?

I answered my own question. All I had to do was publish the app to the server were the chartcontrol web app was located and then it worked just fine.

[RESOLVED] Not able to open .pdf file in IE8

Hi Gurus,

 

I can't open "ONE" page of .pdf file using IE8 and give me an error message "the file is damaged and could not be repaired" when retrieved from SQL Server 2008, but more than one page I can open with no problem.

With Chrome I can open any number of .pdf pages.

The same page that I can't open using IE8 from DB, can be opened directly from hard disk using IE8.

My code in .asxh file:

 

context.Response.ContentType = "application/pdf"
        Dim strm As Stream = ShowNewsImage(imgName)
        If Not strm Is Nothing Then
            Dim buffer As Byte() = New Byte(4095) {}
            Dim byteSeq As Integer = strm.Read(Buffer, 0, 4096)
 
            Do While byteSeq > 0
                context.Response.OutputStream.Write(buffer, 0, byteSeq)
                byteSeq = strm.Read(Buffer, 0, 4096)
            Loop
            context.Response.BinaryWrite(buffer)
        End If

 

Thanks,

Ahmed.

 

I think when I asked for help yesterday was bad timing , and most of gurus were asleep.

So I'm re-sending the question now, hoping that gurus are awake and have time :-)

Thanks,

Ahmed.

 

Hi,

Ahmed A M

can't open "ONE" page of .pdf file using IE8 and give me an error message "the file is damaged and could not be repaired" when retrieved from SQL Server 2008, but more than one page I can open with no problem.

According to the error message ,I would like to suggest you to check the link below for the similar thread which provides some solutions for the same issue.

http://stackoverflow.com/questions/2440518/the-file-is-damaged-and-could-not-be-repaired

Here is an article which describes about 4 ways to send a PDF file to the IE Client in ASP.NET .

Ahmed A M

With Chrome I can open any number of .pdf pages.

The same page that I can't open using IE8 from DB, can be opened directly from hard disk using IE8.

As far as I know some Web sites may not be displayed correctly or may not work correctly in Windows Internet Explorer 8.

However, this problem does not occur in earlier versions of Internet Explorer.

I would like to suggest you to check the article below for the solutions:

Advanced solutions: Some Web sites may not be displayed correctly or work correctly in Windows Internet Explorer 8

Hope it can help you.

Thanks Ming for reply.

 

I found the solution as follows:

I changed the buffer from Object to Byte and it worked !!!

The old code (part of a handler) :

context.Response.ContentType = "application/pdf"
        Dim strm As Stream = ShowNewsImage(imgName)
        If Not strm Is Nothing Then
            Dim buffer As Byte() = New Byte(4095) {}
            Dim byteSeq As Integer = strm.Read(buffer, 0, 4096)

            Do While byteSeq > 0
                context.Response.OutputStream.Write(buffer, 0, byteSeq)
                byteSeq = strm.Read(buffer, 0, 4096)
            Loop
            context.Response.BinaryWrite(buffer)
            context.Response.End()
        End If
    End Sub

    Public Function ShowNewsImage(ByVal imgName As String) As Stream
        Dim conn As String = ConfigurationManager.ConnectionStrings("Connection").ConnectionString
        Dim connection As SqlConnection = New SqlConnection(conn)
        Dim sql As String = "SELECT image FROM Table WHERE ID = @ID"
        Dim cmd As SqlCommand = New SqlCommand(sql, connection)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@ID", imgName)
        connection.Open()
        Dim img As <strong>Object </strong>= cmd.ExecuteScalar()
        Try
            Return New MemoryStream(CType(img, Byte()))
        Catch
            Return Nothing
        Finally
            connection.Close()
        End Try
    End Function

As you see, ExecuteScalar() attached the output to an Object.
I changed this to Byte:

No need to context.Response.OutputStream.Write , it is already impeded in context.Response.BinaryWrite

Took me two days.

context.Response.ContentType = "application/pdf"
        Dim buffer As Byte() = New Byte(4095) {}
        Dim byteSeq As Integer = 0
        Dim conn As String = ConfigurationManager.ConnectionStrings("Connection").ConnectionString
        Dim connection As SqlConnection = New SqlConnection(conn)
        Dim sql As String = "SELECT image FROM Table WHERE ID = @ID"
        Dim cmd As SqlCommand = New SqlCommand(sql, connection)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@ID", imgName)
        connection.Open()

        buffer = cmd.ExecuteScalar()

        context.Response.BinaryWrite(buffer)
        context.Response.End()

[RESOLVED] Image size proble when create pdf using itextsharp dll

thanks in advance

i am  creating pdf using itextsharp dll, but image is not display a proper size in pdf.my code is below

//**************************************************************************************

  '*******************************set Images

        Dim gif As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/Img1.jpg"))
        gif.ScaleToFit(334.0F, 265.0F)
        Dim gif1 As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/Img2.jpg"))

        Dim gif2 As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/Img3.jpg"))
        Dim gif3 As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/Img4.jpg"))
        Dim gif4 As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/Img5.jpg"))
        Dim logo As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/Logo.gif"))

        Dim g As Image = Image.GetInstance(Server.MapPath("~/Images/Img1.jpg"))

        '*******************************************end

        Dim doc As Document = New Document
        PdfWriter.GetInstance(doc, New FileStream(Request.PhysicalApplicationPath + "\2.pdf", FileMode.Create))
        doc.Open()
        Dim table As Table = New Table(3)
        table.BorderWidth = 1
        table.Width = 50
        table.BorderColor = New Color(0, 0, 255)


        table.Padding = 3
        table.Spacing = 1
        ' Dim cell As Cell = New Cell("header")
        Dim cell As Cell = New Cell(logo)
        cell.Header = True
        cell.Colspan = 3
        table.AddCell(cell)


        ' cell = New Cell("example cell with colspan 1 and rowspan 2")
        cell = New Cell(g) '*******************************************************************
        cell.Width = 334
        cell.Header = 265
        cell.Rowspan = 2
        cell.BorderColor = New Color(255, 0, 0)
        table.AddCell(cell)



        Dim cell1_1 As Cell = New Cell(gif1)
        table.AddCell(cell1_1)


        'table.AddCell("2.1")
        Dim cell2_1 As Cell = New Cell(gif2)
        table.AddCell(cell2_1)


        'table.AddCell("1.2")
        Dim cell1_2 As Cell = New Cell(gif3)
        table.AddCell(cell1_2)

        'table.AddCell("2.2")
        Dim cell2_2 As Cell = New Cell(gif4)
        table.AddCell(cell2_2)

        table.AddCell("cell test1")
        cell = New Cell("big cell")
        cell.Rowspan = 2
        cell.Colspan = 2
        cell.HorizontalAlignment = Element.ALIGN_CENTER
        cell.VerticalAlignment = Element.ALIGN_MIDDLE
        cell.BackgroundColor = New Color(192, 192, 192)
        table.AddCell(cell)
        table.AddCell("cell test2")
        doc.Add(table)
        doc.Close()
        Response.Redirect("~/2.pdf")

//******************************************************************************************

Hi himanshu_jadav54Member,

You can try to put the image inside a Chunk and scaling will work.

And use chartImg.SetAbsolutePosition(50, 50); to layout the position.

It is better that you design the image sieze before you use it in the pdf file.

Please check the following link:

http://osdir.com/ml/windows.dotnet.itextsharp.general/2007-06/msg00102.html

http://www.mikesdotnetting.com/Article/82/iTextSharp-Adding-Text-with-Chunks-Phrases-and-Paragraphs