Currently I am working with Adobe AIR and getting practice with ActionScript. My aim is to display a PDF file in a view (iPad view in specific). To do so, I was using URLRequest to specify the location of the PDF and HTMLLoader for load the PDF. However is not working, I read in the documentation the following:
HTMLLoader class. AIR profile support: This feature is supported on
all desktop operating systems, but is not supported on mobile devices
or on AIR for TV devices.
For this reason I would like to ask you folks if you have done something similar, or do you know a workaround for it?
Thanks in advance!
I think StageWebView is what you need.
I've just done a similar thing like this...
var _file:String = "nameOfPdf.pdf";
var webView = new StageWebView();
webView.stage = stage;
webView.viewPort = new Rectangle(20,103,960,640);//specify the clipping mask(x,y,w,h)
//NB I have my pdf file as an included file here (added in the publish panel.
var fPath:String = new File(new File("app:/includes/"+_file).nativePath).url;
webView.loadURL( fPath );
//Alternatively you should be able to navigate to a URL
webView.loadURL("http://www.google.com");
There's an external tool called pdf2swf that will transform a pdf into a working swf that you can add just as any other swf. If all you want is a fixed pdf, you can transform it previously and load the transformed swf directly. But if you want any pdf, you would need a external web server to perform the transformation step.
Related
I am working on an app for my work, where I need to bring in several (around 8 to 9) SWFs into an flash file that is being published to an iPhone. I have the flash projects each of these SWFs were created in, but they did not use the timeline at all, instead each are completely made through code.
I was able to load in the SWFs and get them running on the phone, but only through interpretor mode in Flash. The issue with this is it is not reliable and causes massive slow down after extended use.
I know that the other modes support a single secondary SWF with actionscript.
Here is the code I am using to load in each one.
myLoader = new Loader(); // create a new instance of the Loader class
var url:URLRequest = new URLRequest("JavierNew/app.swf"); // in this case both SWFs are in the same folder
myLoader.load(url); // load the SWF file
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, demoLoaded);
Does anyone have any solutions or suggestions for how I can better import these in a better fashion? To my knowledge there is no way to import the swf or the whole project file into the main .Fla, or a way to combine all the .swfs together.
Any help would be appreciated! Thank you so much!
I have a Delphi XE5 app which downloads and stores PDFs locally on the device. I have a TWebBrowser on the form to view the PDFs and it works perfectly.
I now wish to share the PDF with other applications (eg Safari, Mail, etc) but am really struggling! I have looked at the TShowShareAction action (on the Action List control) but this caters for a Bitmap (photo) to be shared.
I have seen a lot of posts explaining that one should use UIDocumentInteractionController but I cannot find examples of how to use this from within Delphi. I have looked at Apple.Utils but to no avail.
Has anyone used the UIDocumentInteractionController functionality from within a Delphi application to share a file? Any example would be much appreciated!
I have solved this problem by installing D.P.F. Delphi iOS Native Components
I then added a DPFQLPreviewController to my form and open the PDF with the following code:
DPFQLPreviewController1.ShowDoc(filename, false);
This opens the PDF in the standard iOS previewer and this has a button enabling one to share the file with other installed apps that can read the file (eg a PDF app, email, send to printer, etc)
This is by far the simplest solution I have found and works perfectly on the simulator and an actual device.
I'm building a mobile app for IOS using Flash Builder, Flex 4.6 and AIR 3.5. I'm investigating using StageWebView to render some HTML5 content.
What I want to do is to build the content into the app, as opposed to putting it on a server. It's relatively static. But I read (and confirmed) that in-app files can't be used directly by StageWebView. But following a suggestion, I'm have the app copy the content to a temp folder, then create a file:// URL for StageWebView, which seems to work:
// create the view
var webView:StageWebView = new StageWebView();
webView.stage = this.stage;
webView.viewPort = new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight);
// copy the HTML5 content to a temp directory
var src:File = File.applicationDirectory.resolvePath("myFolder");
var temp:File = File.createTempDirectory().resolvePath("myFolder");
copyFolderContentsToAnotherFolder(src,temp);
// what's the URL
var newPath:String = "file://" + temp.nativePath + "/index.html";
// load it
webView.loadURL(newPath);
Is this a bad idea? Will temporary files pile up in my device with no way to delete them?
I also thought of having the app implement an minimal HTTP server by listening on a port and supplying the data for requested files as they come. This would allow us to serve the files to StageWebView from their in-app locations, without copying. We do this in a desktop air app and it works very nicely. But, that approach uses ServerSocket, which I discover is not supported on mobile. Is there an alternative way to do this?
Finally, StageWebView does not work well in the Flash Builder iOS simulator, making debugging difficult. Is it best to just go and get FB 4.7, which (should) allow me to use it with XCode's iOS simulator?
thanks
Well, it seems I CAN directly address the in-app content, I just have to construct a file:// URL for it:
var src:File = File.applicationDirectory.resolvePath("myFolder/index.html");
var newPath:String = "file://" + src.nativePath;
webView.loadURL(newPath);
It's been too long since I thought about this. But as I recall I was able to use in app content without making copies, for iOS. But I am reading today where this might not be possible on Android.
It seems that StageWebView, when used with iOS, works best with remote files. So, I am using some Actionscript code that implements a simple HTTP server, serving up local files. Then, I give StageWebView http urls that use localhost, and a port number. Works swell.
After Adobe updated the SDK - the #Jesse Crosen method does not work for android but only on iOS.
To make it work on Android you have to copy the packaged file like this:
var htmlFile:File = File.applicationDirectory.resolvePath("html/index.html");
var fileDest:File = File.applicationStorageDirectory.resolvePath("html/index.html");
htmlFile.copyTo(fileDest, true);
webView.loadURL("file://" + htmlFile.nativePath);
For anyone looking for a current solution to this problem that's simpler than writing an HTTP server, this is what worked for me (on iOS only):
webView.loadURL(new File(new File("app:/myFolder/index.html").nativePath).url);
But there is a caveat, which is that it seems you can't pass in a query string or hash at the end of the URL. Data can be passed to the HTML content by loading a javascript: URL once the main content is loaded.
There's a page with broader information covering iOS and Android here.
I am developing a data capture web app, primarily targetting iPad usage. Multiple users will primarily capture data on iPads, but then a manager will typically download all captured records onto a PC.
Even though the file download will primarily target PCs, I am pondering whether I should try and support file downloads to the iPad itself.
The server app is an MVC2 ASP.NET app, and I'm using a controller that returns a File result. Test code is as follows:
public ActionResult DownloadResponseData(string profileid)
{
string billcsv = "account_ref,line1,line2,line3";
var data = System.Text.Encoding.UTF8.GetBytes(billcsv);
string filename = "billfor.csv";
return File(data, "text/csv", filename);
}
Even though the majority of people will download to their PCs, because I am supporting full-screen iPad usage I am using the following client-side code to initiate the file download:
var url="/Download/DownloadResponseData?profileid=" + downloadRequest.profileid + "&unique=" + escape(Date());
window.open(url);
This works fine for non-iPad usage - it downloads the file nicely in Chrome.
My questions are numerous: does it make sense to download a CSV file to an iPad? Does an iPad support CSV? Do I need other software on the iPad to view a CSV file? How should I change the above code to download 'cleanly' to an iPad?
When I run the code above on the iPad, then it simply displays the entire CSV file contents within the iPad window - it doesn't seem to recognise the http response as a file.
Sorry for the rather obtuse question. Thanks.
Yes it makes sense to download csv files to the iPad, a number of iPad apps can deal with them successfully.
However, I find that mobile safari is hit or miss - it will download my activity in csv from the Amex web site okay (displays in spreadsheet form and offers to open in Numbers, DropBox, and other apps), but when I click download to get a csv file of activity on the Chase site, nothing at all happens. I even tried a third part web browser, same thing (although they all use the same webkit underneath I guess).
I want to display a list of swfs and allow the user to click on one and have it display. I wanted to use PDF, but need a little more interaction for the user. I've searched around for some swf -> iphone converters, but I want to just display the swf as PART of an app.
Any recommendations?
SWF used to be short for Shockwave/Flash. It is not an "open" file type and requires a huge framework to work correctly, one of which is support for ActionScript. There doesn't seem to be such a framework right now, even Skyfire doesn't do the rendering natively but tries to convert it through a server.
This is possible via CS5->IOS export. It's not the most smooth, but it will allow you to load external swfs. The only gotcya is that the external swfs cannot contain any actionscript (bummer).
Here's a simple example of flash to ios.