What is the process for adding unique colors to the background of a PdfPCell?

I have a snippet of iTextSharp code that sets the background of a cell in a PDF file to green:

PdfPCell cellSec2 = new PdfPCell(parSectionHeading2);
cellSec2.BackgroundColor = BaseColor.GREEN;

The issue I am encountering is that "BaseColor.GREEN" produces a color that is too dark or intense for my liking. I am looking for more of a verdigris shade - something light green or pale green. Is it feasible to specify RGB (or RGBA) values to achieve the desired BackgroundColor?

UPDATE

Combining Bruno's response with this resource, I found the solution I was seeking:

var lightGreen = new BaseColor(204, 255, 204);
cellSec2.BackgroundColor = lightGreen; 

Answer №1

If you're looking for information on iText, we've got you covered! Dive into chapter 10 of our comprehensive guide which focuses on images and color. Don't have the book? No problem - check out some examples from chapter 10.

For a deeper look at colors, take a peek at DeviceColor.cs, where you'll find various examples including:

new GrayColor(0x20) // Represents a gray value
new BaseColor(0f, 1f, 1f) // Defines an RGB color
new CMYKColor(0x00, 0x00, 0xFF, 0xFF) // Indicates a CMYK color

The values for R, G, B, C, M, Y, and K can be specified as floats between 0 and 1 or integers ranging from 0 to 255.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Instructions for incorporating a glyphicon glyphicon-calendar into a bootstrap dropdown using pug

I am a beginner in the world of pug and I'm trying to include the glyphicon glyphicon-calendar in a dropdown menu labeled "All months". .pull-right select.form-control.btn-primary#selectMonth(style="margin-top: -15px;") option(selected="selecte ...

Tips for avoiding a split in the bootstrap navbar when collapsed

I've been searching for hours and still can't figure it out, so I'm really hoping someone can help me solve this before I embarrass myself. My goal is to create a navigation bar similar to the one on steamdb, where the search box remains vi ...

Adjusting the rotation transform by deleting and reapplying canvas is causing the chart to not display data after redrawing

I am facing a challenge with my previous issue and I am exploring different solutions. One approach I am considering is to remove the canvas element completely and then re-add it, effectively resetting all rotations on the canvas. Although this method alm ...

Is it possible to adjust the width of a parent element based on the number of child

In this particular example, I have structured a header with a logo-container positioned on the left side, a menu in the center, and a button on the right. The menu consists of 5 top-level items and 2 sub-menus. <div class="container"> <div cla ...

When elements are arranged side by side without using floats, the alignment at the top is not correct

I am having trouble aligning multiple divs next to each other using inline-flex. They are not lining up properly on top (refer to the screenshot). Interestingly, if I remove the svg, the divs align correctly. ...

What's the solution for aligning these progress bars side by side if floating them doesn't produce the desired result?

I am looking to place two progress bars next to each other, but I have tried using float: left and inline-block without success. I am open to a solution using flex, but I believe there must be a simple fix for this issue. Here is a link to the fiddle for ...

Unable to display ChartJs within the same DIV on the webpage

I'm struggling to display the Pie Chart from ChartJs in the correct DIV when I click from the left DIV. Running the chart directly works fine, but I want them both on the same page in separate DIVs. I have separate HTML files for each link and they wo ...

Creating a clear distinction between a logo and accompanying text

I'm working with bootstrap 5 and I want to add a subtle line right after the logo.png below. The line should be directly connected to the logo with no spaces, and also no spaces between the text and the line. <!-- Bootstrap-5 --> <link hre ...

What is the technique for filtering multiple values using the OR operation in ng-model functions?

Currently, I am using an ng-modal labeled as "myQuery." At the moment, there are two filters in place that look like this: <accordion-group heading="" ng-repeat="hungry_pets in Pets" | filter:{hungry:false} | filter:{name:myQuery}" ... > I have ...

Solving issues with flexboxes in Safari 5.1.7 on Windows

I am currently utilizing flex boxes for managing the layouts of my website. However, it seems that the Safari version for Windows (5.1.7) is outdated and causing all flex boxes to be dysfunctional. On MacOS systems, the same version 12.x works correctly. ...

Is there a way to ensure that the vertical scrollbar remains visible within the viewport even when the horizontal content is overflowing?

On my webpage, I have multiple lists with separate headers at the top. The number of lists is dynamic and can overflow horizontally. When scrolling horizontally (X-scrolling), the entire page moves. However, when scrolling vertically within the lists, I wa ...

Tips for adjusting the hue of a single color in a JPEG image

Is there a way to transform white color to red using only CSS, while leaving the rest of the colors unaffected? This should be accomplished without changing any other elements. ...

Using a border-radius on Internet Explorer 11 reveals the background through the corners

Encountering issues with rounded borders in IE 11 (11.0.9600.18350)? Check out this minimal fiddle for more information: https://jsfiddle.net/7phqrack/2/ Here's the HTML code snippet: <div class="backgrounddiv"> <div class="outer"> ...

color of the foreground/background input in a dropdown menu that

I am attempting to modify the foreground or background color utilized by a dash searchable dropdown when text is entered for searching in the list. The input text is currently black, which makes it extremely difficult to read when using a dark theme. Wit ...

Do we need to include href in the anchor tag?

Why am I unable to display the icon within the <anchor> element without using the href attribute? The icon only appears when I set the href attribute to "". Even if I manage to show the icon by adding href="", adjusting the size with width and height ...

Cannot get the arrow to rotate using Jquery's css() function

Having trouble using css() to rotate my arrow $(function() { $("#arrowAnim").css("transform:","rotate(300deg)"); }); Check out the fiddle here: https://jsfiddle.net/u4wx093a/10/ I've looked for similar issues but can't seem to solve it on my o ...

Align objects in two columns with varying heights properly

I'm trying to arrange items in two columns like Wallapop, but this is the best I've come up with so far: https://i.sstatic.net/1yBqJ.png Here is a JSFiddle link where you can edit the code: https://jsfiddle.net/52qdnLcg/ .parent { backgrou ...

Flexbox design that adapts responsively to display 3 items per row, shifting to 2 items and finally

I have a segment with six elements. For desktop, I would like to display 3 items per row; for medium devices, 2 items per row; and for mobile devices, only 1 item per row. <div class="flex-container"> <div>1</div> <div>2</d ...

How to Customize H1 Font Family in Bootstrap 4

Hey there! I'm trying to figure out how to change the font-family of an H1 element in Bootstrap 4, but I'm having some trouble. I'm pretty new to using Bootstrap so I followed a tutorial on Youtube, but it didn't cover changing the font ...

Footer not positioned at the bottom of the page

I have been experimenting with different ways to keep my footer at the bottom of the page. Initially, I tried using position: static, but the footer ended up above the bottom of the page and the background was visible (similar to the image below). Then, I ...