Get Info From GridView DB And Print It To PDF - Background Color For ITextSharp
Jan 22, 2012
I am making a page that can get some info from a DB from a gridview and then print it to a PDF file. But I am having problems with the background color. If I use this line of code
Code : cell.BackgroundColor = New Color(System.Drawing.ColorTranslator.FromHtml("#008000"))
Then i get this error : System.Drawing.Color' has no constructors
Then I get this error: Value of type 'System.Drawing.Color' cannot be converted to 'iTextSharp.text.BaseColor'.
My code is: (the error is underline)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim cmd As New OleDbCommand()
Dim myAdapter As New OleDbDataAdapter()
Dim myDataSet As New DataSet()
cmd.CommandType = CommandType.Text
cmd.CommandText = "select CustomerID,City,Country from customers"
I found your tutorial online at[URL] .... and finally understand how to send content from a page to a .pdf .
In your tutorial you mention that you modified the iTextSharp Library DLL so the gridview would be rendered with all the background colors. How to modify that DLL. I really want my gridviews to all go to pdfs with pretty formatting, but can't figure out how or what to change?
The output in your sample is great, and would love to use it as a starting point to modify my gridviews.
im using styles to print a gray scale page (see style example) the page is well colored but if i try to print it ignore the background colors.How is it possible to indicate that the page must be printed as it looks on my monitor save for the body background color that would be white instead gray?
I'm having some trouble with editing a gridview row's background color when Editing it.
The thing is, I am using the RowDataBound event method to change e.Row.BackColor based on a criteria when displaying the report( 3 different colors depending on result ). For the rows that don't fall under that criteria, a GridView's property <EditRowStyle BackColor="#999999" /> is applied upon clicking the Edit button.
However, I can't seem to find a way to change the color of those that do fall under the criteria since RowDataBound seems to be called all the time, overriding any changes I make.
I have a GridView. In my RowDataBound event I add attributes for the mouse onclick event, which sets the row's background color to red when the row is clicked. This works. I have a button outside of the GridView. When I click this button, I want to read each row of the GridView, and if its background color is red I want to perform some processing on the row. I tried the following code and even when the row's background is red, I cannot get its background color (bgc is empty).
I am able to change the girdview caption in code like this:GridView1.Caption = "New grid title"But I can not find how to change the background color where this caption (in the entire girdviews heading).
I am pulling information from two different databases (structure is the same) and putting them into two datatables. The problem I am having is figuring how to merge the data togther in a single gridview and change cell background color for only the data in the second datatable.
In my asp.net+vb web I am using the below code to highlight the row...
If e.Row.DataItem("Auth") Is System.DBNull.Value <> True AndAlso e.Row.DataItem("Auth") > e.Row.DataItem("Held") Then e.Row.BackColor = Drawing.Color.LightCoral
I want now only to give colour to the cell in the field and not the entire row ....
i have gridview in which i have a Image button with id (' ImageButton3 ') on click of which i want to hide that corresponding row , by first highlighting it by followed fadeIn effect ....
In my asp.net+vb web I was using this code to change row colour of gridview
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DataItem("bloodgp") Is System.DBNull.Value <> True AndAlso e.Row.DataItem("bloodgp") Then e.Row.BackColor = Drawing.Color.LightGreen End If End If End Sub
Now I want to change the cell backcolour to red for those cells are blank ....
I have a grid with 5 rows and 5 columns, All containing templetefield(Combobox)I am trying to set the background color of my grid cell(contain combobox) depending upon which item is selected. (again, dependent on item selection, so background color is not permanent). How can i achieve this?
I have a master page and set it's back ground color in the body tag <body style="background-color:Red">. Now that is fine for the Master page. How do I set the back ground color of the content page to a different color?
I have a web page that allows a user to view a pdf and print pdf. The print pdf is a copy of the display pdf and i am using ItextSharp to inject the javascript to allow auto printing. I have a method that allows a user to upload a pdf and it calls this method below to copy the display copy into a pdf. Both pdf's are then saved in the database. However , when a user goes to click on the print button on my web page they receive the following error "expected a dict object". below is my code that adds in the auto print, which works fine for me but not on my clients site.
I am doing anything wrong that could be corrupting the file. The original pdf content is passed in as a Binary Object. Also i am using ASP.NET MVC2.
MemoryStream originalPdf = new MemoryStream(Content.BinaryData); MemoryStream updatedPdf = new MemoryStream(); updatedPdf.Write(Content.BinaryData,0, Content.BinaryData.Length);[code]....