AlivePDF
AlivePDF 0.1.5 [RC] new API’s
AlivePDF 0.1.5 RC is finally there and has a lot of new features. As you may have seen, font embedding is now supported and a lot of new things, as a result a lot of new API's have been introduced. Hopefully the documentation is now updated. To get started with those API's here is a brief introduction :
Font Embedding support :
You can embed TTF or PFM fonts now and use them through your PDF document. To use an embedded font, just use the EmbeddedFont class and pass the TTF stream to the EmbeddedFont class constructor, then pass it to the setFont method which will automatically call the addFont method if needed :
var myEmbeddedFont:EmbeddedFont = new EmbeddedFont( new fontStream(), new afmStream(), CodePage.CP1252 );
myPDF.addPage();
myPDF.setFont( myEmbeddedFont, 20 );
myPDF.writeText(12, msg);
As you can see, three parameters are required, the first one is the font stream as a ByteArray, the second one is the AFM file which describes the font, that you can get easily for a font or generate it through a tool like TTF2PT1 or even online here. The third parameter is the codepage to use for your font, which defines the character code mapping between 0 and 255. Note that, only CodePage.1252 is supported for now, but this will be fixed in the final release.
If you want to use standard fonts, known as non-embedded fonts, just use the CoreFont class :
var myCoreFont:IFont = new CoreFont ( FontFamily.HELVETICA_BOLD );
myPDF.addPage();
myPDF.setFont( myCoreFont, 20 );
myPDF.writeText(12, msg);
Cell API additions
New Cell API's have been introduced allowing you to force its content to fit in a cell :
var longText:String = 'This text is way too long.';
p.addCellFitScale(0, 10,shortText,1,1);
p.addCellFitScale(0, 10,longText,1,1,'',1);
p.addCellFitScaleForce(0,10,shortText,1,1,'',1);
p.addCellFitScaleForce(0,10,longText,1,1,'',1);
p.addCellFitSpace(80,10,shortText,1,1);
p.addCellFitSpace(80,10,longText,1,1,'',1);
p.addCellFitSpaceForce(0,10,shortText,1,1,'',1);
p.addCellFitSpaceForce(0,10,longText,1,1,'',1);
EPS Support :
You can now draw EPS or AI files (8.0 version or below required) into your PDF, by using the addEPSImage method, more infos here : http://alivepdf.bytearray.org/?p=358
A drawSector() API has been added to allow you to create dynamic charts very easily, the following code creates a simple pie chart :
var yCenter:int = 60;
var radius:int = 40;
p.lineStyle( new RGBColor ( 0x000000 ), .1 );
p.beginFill( new RGBColor ( 0x0099CC ) );
p.drawSector(xCenter, yCenter, radius, 20, 120);
p.beginFill( new RGBColor ( 0x336699 ) );
p.drawSector(xCenter, yCenter, radius, 120, 250);
p.beginFill( new RGBColor ( 0x6598FF ) );
p.drawSector(xCenter, yCenter, radius, 250, 20);
BeginBitmapFill Drawing API
Just like in Flash Player, a beginBitmapFill API has been added, more infos here : http://alivepdf.bytearray.org/?p=324
Spot Color Support
As requested, Spot color support has been introduced, more infos here : http://alivepdf.bytearray.org/?p=296
Document-level navigation
As requested, document-level navigation has been added, more infos here : http://alivepdf.bytearray.org/?p=279
CSV Grid Export
As requested, the Grid class allows you to export its data as a CSV file: http://alivepdf.bytearray.org/?p=259
So, what's next ? Some final fixes in the UnicodePDF class for other characters like (greek, russian) and a new Invoice API to make invoice generation smooth. I have to finalize the integration of the AlivePDF extension for templates created by Gonzalo. But I may have some interesting news concerning exporting drawn vectors to the PDF, without having to rasterize stuff