我必须使用Flex在pdf中编写文本和图像,但图像不会出现。你能看出错误是什么吗?这是我的代码:
...
private var image:Loader = new Loader;
private var pdf:PDF;
protected function onBtnGeneratePDF(event:MouseEvent):void
{
pdf = new PDF( Orientation.PORTRAIT, Unit.MM, Size.A4 );
pdf.setDisplayMode( Display.FULL_PAGE, Layout.SINGLE_PAGE );
var newPage:Page = new Page ( Orientation.PORTRAIT, Unit.MM, Size.A4 );
pdf.addPage( newPage );
image.load(new URLRequest("bear.jpg"));
image.contentLoaderInfo.addEventListener(Event.CO MPLETE, done);
var fs:FileStream = new FileStream();
var file:File = File.desktopDirectory.resolvePath("testPdf.pdf");
fs.open(file, FileMode.WRITE);
var bytes:ByteArray = pdf.save(Method.LOCAL);
fs.writeBytes(bytes);
fs.close();
}
private function done (e:Event):void {
pdf.addImage(image, null, 20, 20);
}
]]>
</fx:Script>
<s:Button x="10" y="179" label="Generate PDF" click="onBtnGeneratePDF(event)"/>
...