我正在尝试使用 AlivePdf 在我的 flex 应用程序上创建一个 pdf 表:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:mh="mh.components.*"
layout="absolute" width="500" height="500">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import org.alivepdf.colors.RGBColor;
import org.alivepdf.display.Display;
import org.alivepdf.drawing.Caps;
import org.alivepdf.fonts.FontFamily;
import org.alivepdf.fonts.Style;
import org.alivepdf.grid.Grid;
import org.alivepdf.images.ImageFormat;
import org.alivepdf.layout.Orientation;
import org.alivepdf.layout.Resize;
import org.alivepdf.layout.Size;
import org.alivepdf.layout.Unit;
import org.alivepdf.pages.Page;
import org.alivepdf.pdf.PDF;
import org.alivepdf.saving.Method;
import org.alivepdf.visibility.Visibility;
import org.alivepdf.grid.*;
private var myPDF:PDF;
//print chart in pdf format
protected function savePDF(e:MouseEvent):void
{
var myPDF:PDF = new PDF ( Orientation.PORTRAIT, Unit.MM);
myPDF.setDisplayMode(Display.FULL_PAGE);
myPDF.addPage();
myPDF.setXY( 10, 70);
myPDF.textStyle ( new RGBColor ( 0x000000 ) );
var dp:ArrayCollection = new ArrayCollection();
dp.addItem( { firstName : "Bob Geldorf akjaskaj skajs as kajs kaj k dklfj sdkfjl sdkjf ksdj fkjs dkfj ksdj ", lastName : "Groove", city : "Paris" } );
dp.addItem( { firstName : "Bob", lastName : "Wise", city : "Paris" } );
dp.addItem( { firstName : "Bob", lastName : "Wise", city : "Paris" } );
dp.addItem( { firstName : "Bob", lastName : "Wise", city : "Paris" } );
var grid:Grid = new Grid ( dp.toArray(), 200, 100, new RGBColor (0x00DEFF));
myPDF.addGrid( grid, 0, 0, true );
myPDF.save( Method.REMOTE, "coldfusion/pdf.cfm", "inline", "test.pdf" );;
}
]]>
</mx:Script>
<mx:VBox width="100%" height="100%">
<mx:HBox width="100%" backgroundColor="#FFFFFF">
<mx:Spacer width="100%"/>
<mx:Button horizontalCenter="0" label="Save to PDF" height="22" click="savePDF(event)" id="savePDFBtn" toolTip="SAVE TO PDF"/>
</mx:HBox>
</mx:VBox>
奇怪的是脚本创建了一个带有双标题的表,我不知道为什么。您可以在此链接查看生成的 pdf:https ://docs.google.com/viewer?url=prestitiinpdap.biz/pdf/myPDF.pdf