Пример #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Load the license serial number and key from the resource files
            string sn  = GetIni(NSBundle.MainBundle.PathForResource("rdk_sn", "txt"), "SN");
            string key = GetIni(NSBundle.MainBundle.PathForResource("rdk_key", "txt"), "Sign");
            // Initialize the library
            var eRet = FSLibrary.Init(sn, key);

            if (FSErrorCode.Success == eRet)
            {
                // Get the sample PDF file name from the bundle resources
                string pdfFileName = NSBundle.MainBundle.PathForResource("Sample", "pdf");
                // Load the PDF document
                string pdfPassword = "";
                var    doc         = FSPDFDoc.CreateFromFilePath(pdfFileName);
                if (FSErrorCode.Success == doc.Load(pdfPassword))
                {
                    // Create the view
                    var view = new FSPDFViewCtrl(new CoreGraphics.CGRect(
                                                     0, 0, this.View.Frame.Size.Width, this.View.Frame.Size.Height));
                    view.SetDoc(doc);
                    Add(view);
                }
            }
        }
Пример #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.View.BackgroundColor  = UIColor.White;
            this.View.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;


            this.pdfViewControl = new FSPDFViewCtrl(new CoreGraphics.CGRect(
                                                        0, 0, this.View.Frame.Size.Width, this.View.Frame.Size.Height));
            pdfViewControl.SetRMSAppClientId(appClientId: "972b6681-fa03-4b6b-817b-c8c10d38bd20", redirectURI: "com.foxitsoftware.com.mobilepdf-for-ios://authorize");
            pdfViewControl.RegisterDocEventListener(this);

            string configPath = NSBundle.MainBundle.PathForResource("uiextensions_config", "json");

            this.extensionsMgr = new UIExtensionsManager(pdfViewControl, NSData.FromFile(configPath));

            if (null == this.extensionsMgr)
            {
                //        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Extensions manager could not be loaded." delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:nil, nil];
                //        [alert show];
                return;
            }

            FSFileListViewController fileListViewController = new FSFileListViewController();

            fileListViewController.WeakDelegate = this;
            this.pdfViewControl.RegisterDocEventListener(fileListViewController);

            this.rootViewController = new UINavigationController(fileListViewController);
            this.rootViewController.NavigationBarHidden = true;

            this.rootViewController.View.Frame = new CoreGraphics.CGRect(
                0, 0, this.View.Frame.Size.Width, this.View.Frame.Size.Height);
            this.rootViewController.InteractivePopGestureRecognizer.Enabled = false;
            this.AddChildViewController(this.rootViewController);
            this.View.AddSubview(this.rootViewController.View);

            var weakSelf = new WeakReference(this);

            this.extensionsMgr.GoBack = () =>
            {
                if (weakSelf.IsAlive)
                {
                    this.rootViewController.PopViewController(true);
                }
            };

            this.pdfViewControl.ExtensionsManager = extensionsMgr;


            PDFScanManager.InitializeScanner(0, 0);
            PDFScanManager.InitializeCompression(0, 0);

            UIButton button = new UIButton();

            button.TouchUpInside += openScan;
            button.SetImage(UIImage.FromBundle("UIExtensionsResource/scan/scan"), UIControlState.Normal);
            fileListViewController.View.AddSubview(button);
            button.TranslatesAutoresizingMaskIntoConstraints = false;
            button.WidthAnchor.ConstraintEqualTo(60).Active  = true;
            button.HeightAnchor.ConstraintEqualTo(60).Active = true;
            button.BottomAnchor.ConstraintEqualTo(fileListViewController.View.SafeAreaLayoutGuide.BottomAnchor, -15).Active = true;
            button.RightAnchor.ConstraintEqualTo(fileListViewController.View.RightAnchor, -15).Active = true;
        }