コード例 #1
0
 protected override void PrepareConfiguration(PdfActivityConfiguration.Builder configuration)
 {
     // Turn off saving, so we have the clean original document every time the example is launched.
     configuration
     .AutosaveEnabled(false)
     .EnableFormEditing();
 }
コード例 #2
0
        public override void LaunchExample(Context ctx, PdfActivityConfiguration.Builder configuration)
        {
            Task.Factory.StartNew(async() => {
                AndHUD.Shared.Show(ctx, $"Downloading file....", cancelCallback: client.CancelPendingRequests);
                PrepareConfiguration(configuration);
                var docUrl  = "https://pspdfkit.com/downloads/case-study-box.pdf";
                var docPath = Path.Combine(ctx.CacheDir.ToString(), AssetPath);

                using (var file = new FileStream(docPath, FileMode.Create, FileAccess.Write, FileShare.None))
                    await client.DownloadDataAsync(docUrl, file);

                AndHUD.Shared.Dismiss(ctx);

                var jfile  = new Java.IO.File(docPath);
                var docUri = Android.Net.Uri.FromFile(jfile);

                // Start the PSPDFKitAppCompat activity by passing it the Uri of the file.
                if (PSPDFKitGlobal.IsOpenableUri(ctx, docUri))
                {
                    PdfActivity.ShowDocument(ctx, docUri, configuration.Build());
                }
                else
                {
                    AndHUD.Shared.ShowError(ctx, $"This document uri cannot be opened:\n{docUri}", MaskType.Black, TimeSpan.FromSeconds(2));
                }
            });
        }
コード例 #3
0
        public override void LaunchExample(Context ctx, PdfActivityConfiguration.Builder configuration)
        {
            // In this example we use a custom activity to build an intent that allows the user to
            // select a document.
            var intent = new Intent(ctx, typeof(ExternalExampleActivity));

            intent.PutExtra(ExternalExampleActivity.ExtraConfiguration, configuration.Build());
            ctx.StartActivity(intent);
        }
コード例 #4
0
        public override void LaunchExample(Context ctx, PdfActivityConfiguration.Builder configuration)
        {
            // Load and show the signature example PDF.
            // Extract the pdf from assets if not already extracted
            var docUri = Utils.ExtractAsset(ctx, AssetPath);
            var intent = new Intent(ctx, typeof(CustomFragmentActivity));

            intent.PutExtra(CustomFragmentActivity.ExtraUri, docUri);
            ctx.StartActivity(intent);
        }
コード例 #5
0
 // Toggles form highlight color between transparent color and highlight color set in the theme.
 void ToggleFormHighlightColor()
 {
     if (Configuration.Theme == PdfActivityConfiguration.NoTheme)
     {
         Configuration = new PdfActivityConfiguration.Builder(Configuration).Theme(Resource.Style.PSPDFCatalog_Theme_FormSelectionNoHighlight).Build();
     }
     else
     {
         Configuration = new PdfActivityConfiguration.Builder(Configuration).Theme(PdfActivityConfiguration.NoTheme).Build();
     }
 }
コード例 #6
0
        public override void LaunchExample(Context ctx, PdfActivityConfiguration.Builder configuration)
        {
            // Instant example starts with a simple login/connection screen.
            var intent = new Intent(ctx, typeof(InstantExampleConnectionActivity));

            // Pass the configuration to the connection activity. This configuration will
            // be passed to created InstantPdfActivity with downloaded Instant document.
            intent.PutExtra(InstantExampleConnectionActivity.ConfigurationArg, configuration.Build());

            ctx.StartActivity(intent);
        }
コード例 #7
0
        public override void LaunchExample(Context ctx, PdfActivityConfiguration.Builder configuration)
        {
            // Create an instance of the custom data provider. See the implementation details below.
            var dataProvider = new RawResourceDataProvider(Resource.Raw.guide);

            // Start the activity using our data provider.
            var intent = PdfActivityIntentBuilder.FromDataProvider(ctx, dataProvider)
                         .Configuration(configuration.Build())
                         .Build();

            ctx.StartActivity(intent);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        public virtual void LaunchExample(Context ctx, PdfActivityConfiguration.Builder configuration)
        {
            // Extract the pdf from assets if not already extracted
            var docUri = Utils.ExtractAsset(ctx, AssetPath);

            PrepareConfiguration(configuration);

            // Start the PSPDFKitAppCompat activity by passing it the Uri of the file.
            if (PSPDFKitGlobal.IsOpenableUri(ctx, docUri))
            {
                PdfActivity.ShowDocument(ctx, docUri, configuration.Build());
            }
            else
            {
                AndHUD.Shared.ShowError(ctx, $"This document uri cannot be opened:\n{docUri}", MaskType.Black, TimeSpan.FromSeconds(2));
            }
        }
コード例 #10
0
        void ShowPdfDocument(Android.Net.Uri docUri)
        {
            // Show Document using PSPDFKit activity
            var pspdfkitConfiguration = new PdfActivityConfiguration.Builder(ApplicationContext)
                                        .ScrollDirection(PageScrollDirection.Horizontal)
                                        .ShowPageNumberOverlay()
                                        .ShowThumbnailGrid()
                                        .FitMode(PageFitMode.FitToWidth)
                                        .Build();

            if (!PSPDFKitGlobal.IsOpenableUri(this, docUri))
            {
                ShowError("This document uri cannot be opened \n " + docUri.ToString());
            }
            else
            {
                PdfActivity.ShowDocument(this, docUri, pspdfkitConfiguration);
            }
        }
コード例 #11
0
        // Opens a demo document from assets directory, called from Xamarin.Forms's DependencyService, see 'ShowPDF ()' method in XFSamplePage.xaml.cs
        public void ShowPdfActivity()
        {
            // Extract the pdf from assets if not already extracted
            var docUri = Utils.ExtractAsset(CrossCurrentActivity.Current.Activity, sampleDoc);

            // Show Document using PSPDFKit activity
            var pspdfkitConfiguration = new PdfActivityConfiguration.Builder(CrossCurrentActivity.Current.Activity)
                                        .ScrollDirection(PageScrollDirection.Horizontal)
                                        .ShowPageNumberOverlay()
                                        .ShowThumbnailGrid()
                                        .FitMode(PageFitMode.FitToWidth)
                                        .Build();

            if (!PSPDFKitGlobal.IsOpenableUri(this, docUri))
            {
                ShowError("This document uri cannot be opened \n " + docUri.ToString());
            }
            else
            {
                PdfActivity.ShowDocument(CrossCurrentActivity.Current.Activity, docUri, pspdfkitConfiguration);
            }
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        public static PdfActivityConfiguration.Builder GetConfiguration(Context ctx)
        {
            var conf = new PdfActivityConfiguration.Builder(ctx);

            conf.ScrollDirection(PageScrollDirection.ValueOf(Settings.Current.ScrollDirection))
            .LayoutMode(PageLayoutMode.ValueOf(Settings.Current.PageLayout))
            .ScrollMode(Settings.Current.ScrollMode ? PageScrollMode.Continuous : PageScrollMode.PerPage)
            .FitMode(Settings.Current.FitMode ? PageFitMode.FitToWidth : PageFitMode.FitToScreen)
            .RestoreLastViewedPage(Settings.Current.RestoreLastViewedPage)
            .SetUserInterfaceViewMode(UserInterfaceViewMode.ValueOf(Settings.Current.UIViewMode))
            .HideUserInterfaceWhenCreatingAnnotations(Settings.Current.HideUIWhenCreatingAnnotations)
            .ThemeMode(ThemeMode.ValueOf(Settings.Current.ThemeModeSetting))
            .FirstPageAlwaysSingle(Settings.Current.FirstPageAlwaysSingle)
            .ShowGapBetweenPages(Settings.Current.ShowGapBetweenPages)
            .SetSearchType(Settings.Current.InlineSearch ? PdfActivityConfiguration.SearchInline : PdfActivityConfiguration.SearchModular)
            .SetThumbnailBarMode(ThumbnailBarMode.ValueOf(Settings.Current.ThumbnailsBarMode))
            .InvertColors(Settings.Current.InvertPageColors || ThemeMode.ValueOf(Settings.Current.ThemeModeSetting) == ThemeMode.Night)
            .ToGrayscale(Settings.Current.Grayscale)
            .TextSelectionEnabled(Settings.Current.EnableTextSelection)
            .UseImmersiveMode(Settings.Current.ImmersiveMode);

            if (Settings.Current.ShowPageNumberOverlay)
            {
                conf.ShowPageNumberOverlay();
            }
            else
            {
                conf.HidePageNumberOverlay();
            }

            if (Settings.Current.ShowPageLabels)
            {
                conf.ShowPageLabels();
            }
            else
            {
                conf.HidePageLabels();
            }

            if (Settings.Current.EnableSearch)
            {
                conf.EnableSearch();
            }
            else
            {
                conf.DisableSearch();
            }

            if (Settings.Current.ShowThumbnailGrid)
            {
                conf.ShowThumbnailGrid();
            }
            else
            {
                conf.HideThumbnailGrid();
            }

            if (Settings.Current.EnableDocumentOutline)
            {
                conf.EnableOutline();
            }
            else
            {
                conf.DisableOutline();
            }

            if (Settings.Current.EnableAnnotationList)
            {
                conf.EnableAnnotationList();
            }
            else
            {
                conf.DisableAnnotationList();
            }

            if (Settings.Current.EnableAnnotationEditing)
            {
                conf.EnableAnnotationEditing();
            }
            else
            {
                conf.DisableAnnotationEditing();
            }

            if (Settings.Current.EnableFormEditing)
            {
                conf.EnableFormEditing();
            }
            else
            {
                conf.DisableFormEditing();
            }

            //if (Settings.Current.ShowShareAction)
            //	conf.SetEnabledShareFeatures ()
            //else
            //	conf.DisableShare ();

            if (Settings.Current.ShowPrintAction)
            {
                conf.EnablePrinting();
            }
            else
            {
                conf.DisablePrinting();
            }

            return(conf);
        }
コード例 #14
0
 // Allows subclasses to adjust the configuration before displaying the document.
 protected virtual void PrepareConfiguration(PdfActivityConfiguration.Builder configuration)
 {
 }
コード例 #15
0
 protected override void PrepareConfiguration(PdfActivityConfiguration.Builder configuration) => configuration.Title("Case Study Box");