Radaee PDF Xamarin 实施
Radaee PDF Xamarin implementation
首先我需要一个可以解密pdf的内置Pdf Viewer。所以我开始寻找。我尝试了 PDF.js、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:\Users\Tarik\Desktop\HOLOGRAM\Xamarin Forms\Xamarin.Forms.PDFViewer-master\radaee33\obj\Debug\generated\src\Com.Radaee.Pdf.Document.cs:2662
10-23 01:54:59.610 I/MonoDroid(15262): at SmagHologram.PdfViewActivity.InitializePdfRenderer () [0x00097] in C:\Users\Tarik\Desktop\HOLOGRAM\smag_stuff\HoloMag\SmagHologram\SmagHologram\Activities\PdfViewActivity.cs:261
10-23 01:54:59.610 I/MonoDroid(15262): at SmagHologram.PdfViewActivity.OnCreate (Android.OS.Bundle) [0x000c8] in C:\Users\Tarik\Desktop\HOLOGRAM\smag_stuff\HoloMag\SmagHologram\SmagHologram\Activities\PdfViewActivity.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.access00(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)
你知道这里发生了什么吗?或者您知道 Xamarin.Android 的 Radaee 实施的确切方法吗?
这是因为你没有调用 Global.Init();
要使用 radaee PDF 库,您应将本机库和资源复制到您的项目并在应用程序启动时调用 Global.Init()。
您必须先调用 Global.Init()
才能加载本机库。
你可以查看他们的demo on Github, and you can also check this guide
按照指南进行操作后,您只需执行以下操作即可呈现 pdf:
RadaeePDFManager mPdfManager = new RadaeePDFManager();
mPdfManager.Show(this, filePath, password);
首先我需要一个可以解密pdf的内置Pdf Viewer。所以我开始寻找。我尝试了 PDF.js、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:\Users\Tarik\Desktop\HOLOGRAM\Xamarin Forms\Xamarin.Forms.PDFViewer-master\radaee33\obj\Debug\generated\src\Com.Radaee.Pdf.Document.cs:2662
10-23 01:54:59.610 I/MonoDroid(15262): at SmagHologram.PdfViewActivity.InitializePdfRenderer () [0x00097] in C:\Users\Tarik\Desktop\HOLOGRAM\smag_stuff\HoloMag\SmagHologram\SmagHologram\Activities\PdfViewActivity.cs:261
10-23 01:54:59.610 I/MonoDroid(15262): at SmagHologram.PdfViewActivity.OnCreate (Android.OS.Bundle) [0x000c8] in C:\Users\Tarik\Desktop\HOLOGRAM\smag_stuff\HoloMag\SmagHologram\SmagHologram\Activities\PdfViewActivity.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.access00(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)
你知道这里发生了什么吗?或者您知道 Xamarin.Android 的 Radaee 实施的确切方法吗?
这是因为你没有调用 Global.Init();
要使用 radaee PDF 库,您应将本机库和资源复制到您的项目并在应用程序启动时调用 Global.Init()。
您必须先调用 Global.Init()
才能加载本机库。
你可以查看他们的demo on Github, and you can also check this guide
按照指南进行操作后,您只需执行以下操作即可呈现 pdf:
RadaeePDFManager mPdfManager = new RadaeePDFManager();
mPdfManager.Show(this, filePath, password);