如何在 Flex Mobile Project 中显示本地 PDF? [英] How to display local PDF in Flex Mobile Project?
问题描述
我正在运行 Flex 移动项目,我希望我的移动应用程序能够加载和显示本地保存的 pdf 文件.我不想上网访问这些 pdf 文件.
I am running Flex mobile project and I would like my mobile app to be able to load and display pdf files that are saved locally. I do not want to go out to the web to access these pdf files.
我不知道如何使此代码适用于本地保存的文件.
I cant figure out how to make this code work for a locally saved file.
错误消息:错误 #2044:未处理的错误事件:.text=加载错误."
Error MSG: "Error #2044: Unhandled ErrorEvent:. text=Load error."
有人有什么建议吗?
谢谢!
Does anyone have a suggestion?
Thanks!
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
overlayControls="true" title="PDF Display"
viewActivate="view1_viewActivateHandler(event)"
viewDeactivate="removeStageWebViewHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import spark.events.ViewNavigatorEvent;
private var myWebView:StageWebView;
protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void {
myWebView = new StageWebView();
myWebView.viewPort = new Rectangle(5,60,stage.stageWidth-10,stage.stageHeight-140);
myWebView.stage = this.stage;
myWebView.loadURL( "assets/sample.pdf");
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
if (myWebView) {
var point:Point = localToGlobal(new Point());
myWebView.viewPort = new Rectangle(5,60,stage.stageWidth-10,stage.stageHeight-140);
}
}
protected function goBackHandler(event:MouseEvent):void {
navigator.popToFirstView();
}
protected function removeStageWebViewHandler(event:ViewNavigatorEvent):void {
myWebView.stage = null;
// just remove the target and will leave.
}
]]>
</fx:Script>
<s:actionContent>
<s:Button label="BACK" click="goBackHandler(event)"/>
</s:actionContent>
<s:Image x="-1" y="2" source="assets/eventsback.jpg"/>
</s:View>
推荐答案
Android 问题实际上是一个基本的 Android 浏览器操作系统问题.将 AIR StageWebView 视为从您的应用程序中雕刻出来的一个洞,向您展示浏览器及其所有功能.
The Android Issue is actually a fundamental Android Browsers OS Issue. Think of the AIR StageWebView as a Hole carved out of your app showing you the browser and all its capabilities.
如果您的操作系统支持查看 PDF,那么您的应用程序的 StageWebView 也将支持.在 Android 1.0 - 3.0 上,当您尝试查看 PDF 时,它会下载文档并将其手抖到另一个应用程序(如 Acrobat)上.
If your OS supports viewing PDFs, then your App's StageWebView will also. on Android 1.0 - 3.0 when you try and view a PDF it will download the doc it and Hand Shake it off onto another application like Acrobat.
离开去做类似的事情:http://forums.adobe.com/thread/864113
希望这将在最新版本的 Android...4.0 中得到修复
Hopfully this will be fixed in the newest version of Android...4.0
这篇关于如何在 Flex Mobile Project 中显示本地 PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!