When using AlivePDF library in Flex the beginFill method sets font colour rather than background colour

StackOverflow https://stackoverflow.com/questions/6389023

  •  29-10-2019
  •  | 
  •  

Pergunta

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?

Foi útil?

Solução 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:

  1. 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.
  2. The text style should be set too otherwise the text and background will use the same colour

Outras dicas

You should look at the API more:

printPDF.addCell(30, 20, 'Room', 0, 0, '1', 0xFF0000);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top