如何在Flex移动项目中显示本地PDF? [英] How to display local PDF in Flex Mobile Project?

查看:212
本文介绍了如何在Flex移动项目中显示本地PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Flex移动项目,我希望我的移动应用程序能够加载和显示本地保存的PDF文件。我不想出去访问这些pdf文件。



我无法弄清楚如何使这个代码适用于本地保存的文件。



错误MSG:错误#2044:未处理的ErrorEvent :. text =载入错误。

有没有人有一个建议?

谢谢!

 <?xml version =1.0encoding =utf-8?> 
< s:查看xmlns:fx =http://ns.adobe.com/mxml/2009
xmlns:s =library://ns.adobe.com/flex/spark
overlayControls =truetitle =PDF Display
viewActivate =view1_viewActivateHandler(event)
viewDeactivate =removeStageWebViewHandler(event)>

< fx:Script>
<![CDATA [
import mx.events.FlexEvent;
导入spark.events.ViewNavigatorEvent;

private var myWebView:StageWebView;
$ b保护功能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);

$ b覆盖保护函数updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void {
if(myWebView){
var point:Point = localToGlobal点());
myWebView.viewPort = new Rectangle(5,60,stage.stageWidth-10,stage.stageHeight-140);


$ b保护函数goBackHandler(event:MouseEvent):void {
navigator.popToFirstView();


保护函数removeStageWebViewHandler(event:ViewNavigatorEvent):void {
myWebView.stage = null;
//只要移除目标,就会离开。
}

]]>
< / fx:Script>

< s:actionContent>
< s:Button label =BACKclick =goBackHandler(event)/>
< / s:actionContent>

< / s:查看>


解决方案

Android问题实际上是一个基本的Android浏览器操作系统问题。如果您的操作系统支持查看PDF文件,那么您的应用程序的StageWebView也将会在您的应用程序中显示出来,并显示出您的浏览器及其所有功能。 。在Android 1.0 - 3.0中,当您尝试查看PDF时,它将下载文档并将其移到其他应用程序(如Acrobat)上。



离开以执行如下操作:
http://forums.adobe.com/thread/864113



这个问题将会在Android的最新版本中得到解决... 4.0


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.

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>

解决方案

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.

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.

leaving to do something like: http://forums.adobe.com/thread/864113

Hopfully this will be fixed in the newest version of Android...4.0

这篇关于如何在Flex移动项目中显示本地PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆