When using AlivePDF library in Flex the beginFill method sets font colour rather than background colour
-
29-10-2019 - |
Question
Code sample:
var headerRowBackground:RGBColor = new RGBColor(0);
headerRowBackground.b = 58;
headerRowBackground.g = 28;
headerRowBackground.r = 255;
printPDF.beginFill(headerRowBackground);
printPDF.addCell(30, 20, "Room");
The word "Room" is in red, as is the rest of the text in the PDF. I actually want to make the cell background colour red. Anybody know why this doesn't work?
Solution 2
The documentation is wrong, the fill parameter is described as "Link can be internal to do document level navigation (InternalLink) or external (HTTPLink)".
The code to get this working is:
printPDF.beginFill(new RGBColor(0xFF0718));
printPDF.textStyle(new RGBColor(0x000000));
printPDF.addCell(30, 10, "Room", 0, 0, Align.LEFT, 1);
A couple of things about the code:
- The fill parameter should be 0 or 1 rather than the fill value. It just either switches on or off the fill value previously set.
- The text style should be set too otherwise the text and background will use the same colour
OTHER TIPS
You should look at the API more:
printPDF.addCell(30, 20, 'Room', 0, 0, '1', 0xFF0000);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow