首先,我需要一个内置的Pdf查看器,可以解密Pdf。于是我开始寻找。我尝试了pdf文件,Xfinium和;Apitron(他们只是编辑工具),最后我太接近Android L PdfRenderer了。
我无法完成我的任务PdfRenderer,因为它不能打开加密的pdf。我尝试了两个库的组合,比如PdfRenderer &Xfinium,但是整个复制,解密,粘贴和渲染的东西太慢了。
我尝试了Radaee实现,但是我得到了这个错误:
10-23 01:54:59.600 I/MonoDroid(15262): UNHANDLED EXCEPTION:
10-23 01:54:59.610 I/MonoDroid(15262): Java.Lang.UnsatisfiedLinkError: Exception of type 'Java.Lang.UnsatisfiedLinkError' was thrown.
10-23 01:54:59.610 I/MonoDroid(15262): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
10-23 01:54:59.610 I/MonoDroid(15262): at Android.Runtime.JNIEnv.CallIntMethod (intptr,intptr,Android.Runtime.JValue*) [0x00064] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:404
10-23 01:54:59.610 I/MonoDroid(15262): at Com.Radaee.Pdf.Document.Open (string,string) [0x0007e] in C:UsersTarikDesktopHOLOGRAMXamarin FormsXamarin.Forms.PDFViewer-masterradaee33objDebuggeneratedsrcCom.Radaee.Pdf.Document.cs:2662
10-23 01:54:59.610 I/MonoDroid(15262): at SmagHologram.PdfViewActivity.InitializePdfRenderer () [0x00097] in C:UsersTarikDesktopHOLOGRAMsmag_stuffHoloMagSmagHologramSmagHologramActivitiesPdfViewActivity.cs:261
10-23 01:54:59.610 I/MonoDroid(15262): at SmagHologram.PdfViewActivity.OnCreate (Android.OS.Bundle) [0x000c8] in C:UsersTarikDesktopHOLOGRAMsmag_stuffHoloMagSmagHologramSmagHologramActivitiesPdfViewActivity.cs:85
10-23 01:54:59.610 I/MonoDroid(15262): at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <IL 0x00013, 0x00113>
10-23 01:54:59.610 I/MonoDroid(15262): at (wrapper dynamic-method) object.0e73d999-d8ed-4cd1-81a1-4ff16defbc5d (intptr,intptr,intptr) <IL 0x00017, 0x00027>
10-23 01:54:59.610 I/MonoDroid(15262): --- End of managed exception stack trace ---
10-23 01:54:59.610 I/MonoDroid(15262): java.lang.UnsatisfiedLinkError: No implementation found for long com.radaee.pdf.Document.open(java.lang.String, java.lang.String) (tried Java_com_radaee_pdf_Document_open and Java_com_radaee_pdf_Document_open__Ljava_lang_String_2Ljava_lang_String_2)
10-23 01:54:59.610 I/MonoDroid(15262): at com.radaee.pdf.Document.open(Native Method)
10-23 01:54:59.610 I/MonoDroid(15262): at com.radaee.pdf.Document.Open(Document.java:406)
10-23 01:54:59.610 I/MonoDroid(15262): at md5d55d75e2e923f69563bc550581d20657.PdfViewActivity.n_onCreate(Native Method)
10-23 01:54:59.610 I/MonoDroid(15262): at md5d55d75e2e923f69563bc550581d20657.PdfViewActivity.onCreate(PdfViewActivity.java:29)
10-23 01:54:59.610 I/MonoDroid(15262): at android.app.Activity.performCreate(Activity.java:6500)
10-23 01:54:59.610 I/MonoDroid(15262): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
10-23 01:54:59.610 I/MonoDroid(15262): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3072)
10-23 01:54:59.610 I/MonoDroid(15262): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3218)
10-23 01:54:59.610 I/MonoDroid(15262): at android.app.ActivityThread.access$1000(ActivityThread.java:198)
10-23 01:54:59.610 I/MonoDroid(15262): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1676)
10-23 01:54:59.610 I/MonoDroid(15262): at android.os.Handler.dispatchMessage(Handler.java:102)
10-23 01:54:59.610 I/MonoDroid(15262): at android.os.Looper.loop(Looper.java:145)
10-23 01:54:59.610 I/MonoDroid(15262): at android.app.ActivityThread.main(ActivityThread.java:6837)
10-23 01:54:59.610 I/MonoDroid(15262): at java.lang.reflect.Method.invoke(Native Method)
10-23 01:54:59.610 I/MonoDroid(15262): at java.lang.reflect.Method.invoke(Method.java:372)
10-23 01:54:59.610 I/MonoDroid(15262): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
10-23 01:54:59.610 I/MonoDroid(15262): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
你知道这里发生了什么吗?或者你知道Radaee在Xamarin.Android上的具体实现方式吗?
这是因为你没有调用Global.Init();
要使用radaee PDF库,你需要将本地库和资源复制到你的项目中,并在APP启动时调用Global.Init()。
必须先调用Global.Init()
才能加载本机库。
你可以在Github上查看他们的演示,你也可以查看这个指南
在遵循指南之后,您只需要执行以下操作来呈现pdf:
RadaeePDFManager mPdfManager = new RadaeePDFManager();
mPdfManager.Show(this, filePath, password);