protected async override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == requestOpenDocument && resultCode == Result.Ok && data != null) { Android.Net.Uri uri = null; // Some URIs can be opened directly, including local filesystem, app assets, and content provider URIs. if (!PSPDFKitGlobal.IsOpenableUri(this, data.Data)) { // The Uri cannot be directly opened. Download the PDF document from the uri, for local access. AndHUD.Shared.Show(this, "Downloading file", 0); var docPath = Path.Combine(ApplicationContext.CacheDir.ToString(), DateTime.Now.Ticks.ToString() + ".pdf"); var progressReporter = new Progress <DownloadBytesProgress> (); progressReporter.ProgressChanged += (s, args) => AndHUD.Shared.Show(this, "Downloading file", (int)(100 * args.PercentComplete)); uri = await Utils.DownloadDocument(this, data.Data, docPath, progressReporter); AndHUD.Shared.Dismiss(this); } else { uri = data.Data; } var intent = PdfActivityIntentBuilder .FromUri(this, uri) .Configuration(configuration) .Build(); StartActivity(intent); Finish(); } }
public override void LaunchExample(Context ctx, PdfActivityConfiguration.Builder configuration) { PrepareConfiguration(configuration); // Extract the pdf from assets if not already extracted var docUri = Utils.ExtractAsset(ctx, AssetPath); var intent = PdfActivityIntentBuilder.FromUri(ctx, docUri) .Configuration(configuration.Build()) .ActivityClass(Java.Lang.Class.FromType(typeof(FormFillingActivity))) .Build(); ctx.StartActivity(intent); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == requestOpenDocument && resultCode == Result.Ok && data != null) { var uri = data.Data; // Some URIs can be opened directly, including local filesystem, app assets, and content provider URIs. if (PSPDFKitGlobal.IsOpenableUri(this, uri)) { var intent = PdfActivityIntentBuilder.FromUri(this, uri) .Configuration(configuration) .Build(); StartActivity(intent); Finish(); } else { // The Uri cannot be directly opened. Download the PDF document from the uri, for local access. // Find the DownloadProgressFragment for showing download progress, or create a new one. var downloadFragment = SupportFragmentManager?.FindFragmentByTag(downloadProgressFragment)?.JavaCast <DownloadProgressFragment> (); if (downloadFragment == null) { var job = DownloadJob.StartDownload(new DownloadRequest.Builder(this).Uri(uri).Build()); downloadFragment = new DownloadProgressFragment(); downloadFragment.Show(SupportFragmentManager, downloadProgressFragment); downloadFragment.Job = job; } // Once the download is complete we launch the PdfActivity from the downloaded file. downloadFragment.Job.Complete += (sender, e) => { var intent = PdfActivityIntentBuilder.FromUri(this, Android.Net.Uri.FromFile(e.P0)) .Configuration(configuration) .Build(); StartActivity(intent); Finish(); }; } } }
public override void LaunchExample(Context ctx, PdfActivityConfiguration.Builder configuration) { // Our test certificate is self-signed, so we need to add it to trusted certificate store for it to validate. Otherwise // the new signature won't validate. Since PSPDFKit and other readers (like Acrobat) will warn when using self-signed certificates // your app should use a CA issued certificate instead. AddJohnAppleseedCertificateToTrustedCertificates(ctx); // The signer is a named entity holding a certificate (usually a person) and has a display name shown in the app. Registration of the Signer instance // has to happen using a unique string identifier. The signer can be associated with a signature for signing the document. var johnAppleseed = new Pkcs12Signer("John Appleseed", Android.Net.Uri.Parse("file:///android_asset/JohnAppleseed.p12")); SignatureManager.AddSigner("john_appleseed", johnAppleseed); // Load and show the signature example PDF. // Extract the pdf from assets if not already extracted var docUri = Utils.ExtractAsset(ctx, AssetPath); var intent = PdfActivityIntentBuilder.FromUri(ctx, docUri) .Configuration(configuration.Build()) .Build(); ctx.StartActivity(intent); }