
Introduction
Adobe AIR and ActionScript 3 (AS3) offer a powerful framework for cross-platform application development. If you’re building an AIR-based application and need to open PDF files from within the app on PC, macOS, iOS, or Android, you’re in the right place.
Opening PDFs in Adobe AIR is not natively supported like HTML or images. However, you can achieve this using a combination of URL handling, native extensions (ANE), and platform-specific tricks.
This guide will walk you through how to open a PDF file in Adobe AIR using AS3—no matter which platform your application is targeting.
What You’ll Need
To follow this tutorial, make sure you have:
-
Adobe AIR SDK
-
Adobe Animate or Flash Builder (for development)
-
Access to the ANE (Adobe Native Extension) SDK (for mobile)
-
A test PDF file to open
Step-by-Step Guide to Open PDF on PC and Mac
For desktop applications, the best way is to use the built-in navigateToURL()
function to open the PDF with the default system viewer.
✅ AS3 Code Example (PC/Mac)
import flash.net.URLRequest;
import flash.net.navigateToURL;
var pdfPath:String = "file:///C:/path/to/your/file.pdf"; // Use local path or URL
var request:URLRequest = new URLRequest(pdfPath);
navigateToURL(request, "_blank");
📌 Notes:
-
On macOS, use a path like:
file:///Users/YourName/Documents/sample.pdf
-
Make sure the file path is absolute and that AIR has permission to access it
Step-by-Step Guide for Mobile (Android & iOS)
Mobile operating systems don’t allow the same file access or system calls as desktops. Here, you’ll need Adobe Native Extensions (ANE).
📱 Option 1: Using openWithDefaultApplication
(Android)
Adobe AIR for Android allows some native intent handling.
import flash.filesystem.File;
var file:File = File.documentsDirectory.resolvePath("sample.pdf");
file.openWithDefaultApplication();
🔒 Permissions Required:
In your AndroidManifest.xml
, add:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
🍏 Option 2: Using ANE for iOS (Recommended)
iOS doesn’t allow launching default apps directly. Use a native extension like:
-
Distriqt’s PDFViewer ANE
-
Milkman Games iOS Utilities ANE
These allow you to invoke native UI components and show the PDF from your application.
Using ANEs (Adobe Native Extensions)
ANE acts as a bridge between AS3 and the device’s native functionalities. To use one:
-
Download a suitable ANE (e.g., distriqt.com)
-
Add it to your project’s library path
-
Initialize and call the PDF viewing method
Example (Distriqt PDFViewer):
import com.distriqt.extension.pdf.PDF;
PDF.service.view( File.applicationDirectory.resolvePath("sample.pdf") );
Embedding or Streaming PDFs
Adobe AIR doesn’t render PDFs directly in the app window. But if you want to embed or simulate this:
🌀 Option 1: Convert PDF Pages to Images
Render PDF as JPG/PNG using a server-side tool, then display as:
var loader:Loader = new Loader();
loader.load(new URLRequest("page1.png"));
addChild(loader);
🌀 Option 2: Open in WebView (Using StageWebView)
import flash.media.StageWebView;
import flash.geom.Rectangle;
var webView:StageWebView = new StageWebView();
webView.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
webView.loadURL("https://example.com/sample.pdf");
Works well on mobile for online PDFs.
PDF Handling Best Practices
-
Always check for file existence before opening
-
Use try-catch blocks for error handling
-
On iOS, files must be in
applicationDirectory
ordocumentsDirectory
-
For Android, test on real devices due to emulator limitations
Tools and Resources
FAQ
Q: Can I embed a PDF directly into the AIR app window?
No, Adobe AIR does not support embedded PDF rendering. Use external viewers or convert to images.
Q: Can I open online PDFs from a URL?
Yes, use navigateToURL()
or StageWebView
to open web-hosted PDFs.
Q: Do I need different code for Android and iOS?
Yes. iOS requires ANEs to open PDFs, while Android allows direct launching with openWithDefaultApplication()
.
Conclusion
While Adobe AIR does not provide native PDF rendering, it offers multiple flexible ways to open PDF files across platforms using navigateToURL()
, StageWebView
, or native extensions. Whether you’re building a desktop app or targeting iOS/Android, the methods above ensure smooth PDF handling using AS3.
Call to Action
Need help integrating PDF functionality into your Adobe AIR project?
📩 Contact the experts at Sadedar Digital Solutions for Adobe AIR development, cross-platform app support, and custom AS3 solutions.