1
我是新來flex,我不知道如何將pdf文件轉換爲字節數組。我也嘗試過在谷歌也沒有結果,但你更喜歡如何將PDF文件轉換成字節數組和檢索字節數組成pdf文件在flex應用程序中。如何將pdf文件轉換爲字節數組,在flex桌面應用程序中將字節數組檢索爲pdf文件?
迫切....
先謝謝了。(沒有什麼不可能)
我是新來flex,我不知道如何將pdf文件轉換爲字節數組。我也嘗試過在谷歌也沒有結果,但你更喜歡如何將PDF文件轉換成字節數組和檢索字節數組成pdf文件在flex應用程序中。如何將pdf文件轉換爲字節數組,在flex桌面應用程序中將字節數組檢索爲pdf文件?
迫切....
先謝謝了。(沒有什麼不可能)
如果你有一個Flex(網絡)應用程序,您將使用FileReference
類
private var ref:FileReference;
//This generally is a mouse click handler, to initiate the process of file reading (i.e. Selection)
public function mc():void {
ref=new FileReference();
ref.addEventListener(Event.SELECT, fileSelected);
ref.browse([new FileFilter("PDF Files (*.pdf)", "*.pdf")]);
}
private function fileSelected(e:Event):void {
ref.removeEventListener(Event.SELECT, fileSelected);
ref.addEventListener(Event.COMPLETE, fileOpen);
ref.load();
}
private function fileOpen(e:Event):void {
var byteArrayToProcess:ByteArray=ref.data;
}
如果您有AIR(桌面/手機)應用程序,則可以直接使用File
和FileStream
類。
public function mc():void {
var f:File=new File("path/to/file");
var s:FileStream=new FileStream();
s.open(f, FileMode.READ);
var byteArrayToProcess:ByteArray=new ByteArray()
s.readBytes(byteArrayToProcess, 0, s.bytesAvailable);
}
你爲什麼需要pdf作爲bytearray?你通過FileReference訪問pdf嗎?請發佈您的代碼... – 2012-03-28 07:14:04