tags:

views:

187

answers:

2

I have AlivePDF with Flex, making a webapp. I've got version 1.5 of AlivePDF but can't seem to set the font:

myPDF.setFont( FontFamily.ARIAL, Style.BOLD );

this gives an error of "1067: Implicit coercion of a value of type String to an unrelated type int."

Am I doing it wrong?

+1  A: 

Most likely you're trying to set a int value where you should be using a String.

If you review the AlivePDF ASDocs for the setFont method, you'll see that it takes three arguments, an instance of IFont, the size as an int, and a Boolean that tells whether or not the font is underlined.

You are trying to set the font size (which should be an int) with a string value (Style.BOLD )

www.Flextras.com
A: 

There was a change in the 1.5RC API. The first parameter in the setFont function now expects an iFont rather than a string as I think it was before.

The docs don't really seem to say much but I did find reference to it on the alivePDF website

An example from there is here :

var msg:String = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."

var myEmbeddedFont:EmbeddedFont = new EmbeddedFont( new fontStream(), new afmStream(), CodePage.CP1252 );
myPDF.addPage();
myPDF.setFont( myEmbeddedFont, 20 );
myPDF.writeText(12, msg);

More info here :

http://alivepdf.bytearray.org/?p=440

meerkatlookout