• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Load a PDF in StageWebView - iOS

New Here ,
Nov 23, 2011 Nov 23, 2011

Copy link to clipboard

Copied

I am trying to create an iOS app that loads my companies product catalogue into a webview stage. I cannot figure out after a lot of google how to access this local file, although external files load fine. I'm trying to use the "file:" command. I'm doing this in flash builder.

<![CDATA[

                              import flash.display.MovieClip;

                              import flash.media.StageWebView;

                              import flash.geom.Rectangle;

 

                              var webView:StageWebView = new StageWebView();

                              var yOffset = 47

                              {

                                             public function FestoKP() {

                                                       webView.stage = this.stage;

       webView.viewPort = new Rectangle( 0, yOffset, stage.stageWidth, stage.stageHeight - yOffset);

       webView.loadURL( "file:///asset/Festo_KP_Catalogue.pdf" );

                                                       closeBtn.visible = true

       }

       public function Close() {

       webView.stage = null;

       closeBtn.visible = false;

       }

                              }

Views

8.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 02, 2012 Feb 02, 2012

Copy link to clipboard

Copied

I am on the same boat.  Did you ever find a good working example? -I'm about to give up.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 02, 2012 Feb 02, 2012

Copy link to clipboard

Copied

Yes, I actually did finally figure it out. I ended up scraping this method though because although it works very well in iOS, it does not work on android. Would you still like me to post the code? I ended up completing this project in Xcode instead, so it'll take a bit to dig up.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 07, 2012 Feb 07, 2012

Copy link to clipboard

Copied

These guys at "CultCreative" seem to have the ideal solution for FB (it even checks to see if a newer .pdf is on a server)  but my project was built in Flash Pro CS5.5 so again just want to load a few local .pdf files which would be bundled up with the app. 

http://www.cultcreative.com/tutorials/11/13/2011/local-file-access-editing-for-android-and-ios/

I'm still interested in the method you used for iOS if it works well with Air (3.1) for iOS.   However, I am determined to find a way of using Flash Pro CS5.5 to do so.   Thanks! -if you can find it, and think your AS3 from FB would work for me. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 07, 2012 Feb 07, 2012

Copy link to clipboard

Copied

In the example below, I included a close button to close the webview. This function is at the bottom. Y-offset is the height of the toolbar at the top.

<fx:Script>

<![CDATA[

import flash.display.MovieClip;

import flash.media.StageWebView;

import flash.geom.Rectangle;

var webView:StageWebView = new StageWebView();

var yOffset = 45;

var yTabs = 54;

//var yOffset = 90;

//var yTabs = 107;

private function loadDSPF():void {

webView.stage = this.stage;

webView.viewPort = new Rectangle( 0, yOffset, stage.stageWidth, stage.stageHeight - yOffset );

var fileName:String = "foldername/filename";

var sourceFile = File.applicationDirectory.resolvePath( fileName );

var workingFile = File.createTempFile();

try

{

sourceFile.copyTo( workingFile, true );

// You have to rename the temp file

var renamedTempFile:File = workingFile.resolvePath(workingFile.nativePath + fileName);

workingFile.moveTo(renamedTempFile, true);

webView.loadURL( renamedTempFile.url );

closeBtn.visible = true;

}

catch (err:Error) { }

}

public function Close() {

webView.stage = null;

closeBtn.visible = false;

allBtn.enabled = true;

}

]]>

</fx:Script>

hope that helps. I can explain anything else if you need.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 17, 2013 Feb 17, 2013

Copy link to clipboard

Copied

LATEST

This was perfect thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines