2012-05-04 22 views
2

我有一个应用程序是从Flash CS5.5构建的,使用AIR3.1导出并通过Apple的企业安装程序分发(允许我绕过Appstore批准) 。是否可以从iOS的AIR应用导出PDF

我现在试图将PDF(使用AlivePDF生成)以某种方式导出到iPad中,或者导入到iBooks中,或者只是在Safari中打开它。

这是我用于我的桌面版本的应用程序。尽管脚本非常混乱,但它完成了工作。我只是不知道如何在这个转换并使它在iPad上

//Populate listbox component from array 

function noEmpty(item:*, index:int, array:Array):Boolean{ 
    return item != undefined; 
} 

for(var i:int = 0; i < MovieClip(root).selectedProducts.length; i++) { 
    if(MovieClip(root).selectedProducts[i] != undefined){ 
     selectedProductsText.dataProvider.addItem({label: MovieClip(root).selectedProducts[i]}); 
    } 
} 

var myTextFormat:TextFormat = new TextFormat(); 
myTextFormat.size = 20; 
myTextFormat.font = "Arial"; 
myTextFormat.color = 0x000000; 
myTextFormat.leftMargin = 30; 
selectedProductsText.rowHeight = 40; 

selectedProductsText.setRendererStyle("textFormat", myTextFormat); 

//AlivePDF, generate PDF 

import org.alivepdf.pdf.PDF; 
import org.alivepdf.layout.Orientation; 
import org.alivepdf.layout.Size; 
import org.alivepdf.layout.Unit; 
import org.alivepdf.display.Display; 
import org.alivepdf.saving.Method; 
import org.alivepdf.fonts.FontFamily; 
import org.alivepdf.fonts.Style; 
import org.alivepdf.colors.RGBColor; 
import com.adobe.images.*; 

function convertString(_value:String):String 
{ 
var returnString:String = ""; 
var _chr:String = String.fromCharCode(13); 
var tempArray:Array = _value.split(_chr); 
for(var i:uint = 0; i < tempArray.length; i++) 
    { 
    returnString += tempArray[i] + "\n"; 
    } 
    return returnString; 
} 

var pdf:PDF = new PDF(); 

pdf.setDisplayMode (Display.REAL);  
pdf.addPage(); 

pdf.writeText(7, convertString( MovieClip(root).selectedProducts.filter(noEmpty).join('\n') )); 

var buffer:ByteArray = pdf.save(Method.LOCAL); 
var file:FileReference = new FileReference(); 

//save PDF button 

btnPdf.addEventListener(MouseEvent.CLICK, generatePDF); 

function generatePDF (e:MouseEvent) 
{ 
    file.save(buffer, "Product Selection List.pdf"); 
} 
+0

什么部分不专门在ios上工作? (偏离主题,但我无法在堆栈溢出中找到私人消息选项):Air 3 for ios如何为您工作?我一直在考虑自己试一试。 – user1103976

+0

user1103976:我不知道将文件存储在iDevice上的事实。苹果公司对他们的操作系统并不是很开放,所有的事情都是屁股疼痛。 虽然iOS上的AIR3似乎运行正常。这是我在开发应用程序时没有学习的唯一方法。Objective C性能不如桌面/笔记本电脑明显,但如果保持优化,它不会太糟糕。 – user1172903

回答

0

工作做完与AIR为iOS的一些工作,我会说你的问题将是,你需要更改的文件是如何保存并存储在设备上。

您需要的文件到应用程序存储目录中保存有这样的事情,我用来储存JPG图片:

f = File.documentsDirectory.resolvePath(imagename+".jpg");  
stream = new FileStream(); 
stream.open(f, FileMode.WRITE);           
j = new JPGEncoder(80);  
bytes = new ByteArray(); 
bytes = j.encode(snapShot.bitmapData); 
stream.writeBytes(bytes, 0, bytes.bytesAvailable); 
stream.close(); 

我不知道怎么样,或者如果它甚至有可能通过空气发送pdf到iBooks。您可以在您的应用程序中使用StageWebView来显示PDF。

+0

谢谢,这有些帮助。我不认为这是可能的,但我只是希望有人可能证明我错了。 – user1172903

相关问题