-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathNativePDF.as
More file actions
69 lines (64 loc) · 1.36 KB
/
NativePDF.as
File metadata and controls
69 lines (64 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package darkBox
{
import flash.filesystem.File;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import flash.utils.getDefinitionByName;
internal class NativePDF
{
/**Native pdf loader*/
private static var PDFReaderClass:Class,
PDFReaderSupports:int = -1 ;
private static var pdfReaderInstant:* ;
public static function isSupports():Boolean
{
setUp();
if(PDFReaderSupports==1)
{
return true ;
}
else
{
return false ;
}
}
/**Call this function first*/
public static function setUp():void
{
if(PDFReaderSupports==-1)
{
try
{
PDFReaderClass = getDefinitionByName("com.janumedia.ane.pdfreader.PDFReader") as Class ;
pdfReaderInstant = new PDFReaderClass();
PDFReaderSupports = 1 ;
}
catch(e)
{
PDFReaderClass = null ;
PDFReaderSupports = 0 ;
};
}
}
public static function openPDFReader(pdfFile:File):void
{
if(isSupports())
{
if(pdfReaderInstant.hasPDFApplication(pdfFile))
{
trace("PDF is loaded");
}
else
{
trace("Use has no PDF reader");
navigateToURL(new URLRequest("market://delails?id=com.adobe.reader"));
navigateToURL(new URLRequest("https://play.google.com/store/apps/details?id=com.adobe.reader"));
}
}
else
{
throw "PDF reader is not supporting" ;
}
}
}
}