Packagecom.myflashlab.air.extensions.pdf
Classpublic class PdfViewer
InheritancePdfViewer Inheritance flash.events.EventDispatcher

PdfViewer class lets you open pdf files right from your Air mobile apps. On both Android and iOS, it will open a dialog and lets you select which program you wish to use for opening the file.

Before calling the run command on the extension, you must make sure that the File object you are passing actually exists

On iOS side, the dialog will always open but on the Android side, if there is no application installed on the device to be able to handle PDF files, the extension will return false. So you should probably promote that user to install Acrobat reader app or any other application that can handle PDF files.

Important: on Android, you must copy the pdf file to File.cacheDirectory. The ANE is using the FileProvider feature on Android devices

View the examples



Public Methods
 MethodDefined By
  
PdfViewer($useAirPrefixForAndroid:Boolean = true)
ANE constructor will initialize the extension in your project.
PdfViewer
  
dispose():void
to dispose the extension
PdfViewer
  
run($file:File):Boolean
open a dialog so user can choose what application he likes to use for opening this pdf file. On Android, if there is ONLY one app available on user's device to handle PDF files, no dialog will open and instead, the file will directly open in the related application.
PdfViewer
Public Constants
 ConstantDefined By
  EXTENSION_ID : String = com.myflashlab.air.extensions.pdfViewer
[static]
PdfViewer
  VERSION : String = 3.0.0
[static]
PdfViewer
Constructor Detail
PdfViewer()Constructor
public function PdfViewer($useAirPrefixForAndroid:Boolean = true)

ANE constructor will initialize the extension in your project.

Parameters
$useAirPrefixForAndroid:Boolean (default = true) — If you are using AIR CLI to compile your app to manually remove the initial air. prefix from your app package name, you must set this parameter to false . Otherwise, it must be true.
Method Detail
dispose()method
public function dispose():void

to dispose the extension

run()method 
public function run($file:File):Boolean

open a dialog so user can choose what application he likes to use for opening this pdf file.

On Android, if there is ONLY one app available on user's device to handle PDF files, no dialog will open and instead, the file will directly open in the related application. And if there is NO app available to handle PDF files, this method will return false and also the PdfViewerEvent.STATUS listener will dispatch an onError message.

On Android side, you must open a pdf file from File.cacheDirectory before you can open it.

On iOS side, your file can be anywhere! File.applicationDirectory, File.applicationStorageDirectory or File.documentsDirectory they all work.

Parameters

$file:File

Returns
Boolean
Constant Detail
EXTENSION_IDConstant
public static const EXTENSION_ID:String = com.myflashlab.air.extensions.pdfViewer

VERSIONConstant 
public static const VERSION:String = 3.0.0

Examples
The following example will tell you how to initialize this extension and read barcodes
     import com.myflashlab.air.extensions.pdf.
     
     var _ex:PdfViewer = new PdfViewer();
     _ex.addEventListener(PdfViewerEvent.STATUS, onStatus);
     
     trace(_ex.run(File.cacheDirectory.resolvePath("sample_pdfViewer_ane.pdf")));
     
     private function onStatus(e:PdfViewerEvent):void
     {
         trace(e.param);
     }