예제 #1
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     SetContentView(Resource.Layout.activity_main);
     pdfView = FindViewById <PdfView>(Resource.Id.pdfView);
     DisplayFromAsset("sample.pdf");
 }
예제 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var pdfView = new PdfView();

            pdfView.TranslatesAutoresizingMaskIntoConstraints = false;
            View.AddSubview(pdfView);

            pdfView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active   = true;
            pdfView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true;
            pdfView.TopAnchor.ConstraintEqualTo(View.TopAnchor).Active           = true;
            pdfView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor).Active     = true;

            var document = new PdfDocument(new NSUrl("https://bayes.wustl.edu/etj/articles/random.pdf"));

            pdfView.Document   = document;
            pdfView.AutoScales = true;


            // Perform any additional setup after loading the view, typically from a nib.
            //UILabel label = new UILabel(new CGRect(0, 200, View.Frame.Size.Width, 50));
            //label.Text = "Tutorial";
            //label.Font.WithSize(36);
            //View.Add(label.ViewForBaselineLayout);

            //this.View.AddSubview(uIScrollView);
        }
예제 #3
0
        internal void Initialize(PdfView pdfView)
        {
            PDFView = pdfView;

            // Register event handlers
            PDFView.InitializationCompletedHandler += PDFView_InitializationCompletedHandler;

            PDFView.OnDocumentOpened += (sender, document) => {
                Events.Add("Document Opened From " + (document.DocumentSource.GetFile() != null ? "StorageFile" : "IBuffer"));

                document.AnnotationsCreated += (view, annotations) => { AnnotationEvent("created", annotations); };
                document.AnnotationsDeleted += (view, annotations) => { AnnotationEvent("deleted", annotations); };
                document.AnnotationsUpdated += (view, annotations) => { AnnotationEvent("updated", annotations); };

                sender.Controller.OnCurrentPageChanged += (controller, currentPage) => Events.Add($"Changed to page {currentPage}");

                sender.OnViewStateChanged += (controller, viewState) =>
                {
                    if (viewState.ZoomFactor != LastZoomFactor)
                    {
                        LastZoomFactor = viewState.ZoomFactor;
                        Events.Add($"ViewState changed: ZoomFactor {LastZoomFactor}");
                    }
                };
            };
        }
예제 #4
0
        public PdfContainerView(NSUrl uri, bool ocr)
        {
            BackgroundColor = UIColor.White;

            title = new UILabel();
            title.TextAlignment = UITextAlignment.Center;
            title.TextColor     = Colors.DarkGray;
            title.Font          = UIFont.FromName("HelveticaNeue-Bold", 13f);
            title.Lines         = 0;

            AddSubview(title);

            content             = new PdfView();
            content.DisplayMode = PdfDisplayMode.SinglePageContinuous;
            content.AutoScales  = true;
            content.Document    = new PdfDocument(uri);
            AddSubview(content);

            if (ocr)
            {
                title.Text =
                    "Good job! You created a sandwich .pdf.\n" +
                    "Go ahead, try to select part of the text of your saved file";
            }
            else
            {
                title.Text =
                    "Good job! You saved a plain pdf.\n" +
                    "Try to select part of your text, you won't be able to";
            }
        }
        public ActionResult RePrint()
        {
            List <MovementEntryVM> aList = (List <MovementEntryVM>)Session["CartList"];

            if (aList != null && aList.Any())
            {
                List <PdfView> pdfList = new List <PdfView>();

                foreach (var mo in aList)
                {
                    PdfView aPdfView = new PdfView();

                    aPdfView.OrganizationId   = mo.OrganizationId;
                    aPdfView.OrganizationName = mo.OrganizationName;
                    aPdfView.AssetId          = mo.AssetId;
                    aPdfView.AssecCode        = mo.Code;
                    aPdfView.AssetSerialNo    = mo.SerialNo;
                    aPdfView.GeneralCategory  = mo.GeneralCategoryName;
                    aPdfView.Category         = mo.CategoryNme;
                    aPdfView.Brand            = mo.BrandName;
                    aPdfView.FromBranch       = mo.BranchName;
                    aPdfView.ToBranch         = branchManager.GetById(mo.BranchId).Name;
                    aPdfView.MovedBy          = mo.MoveBy;
                    aPdfView.Date             = mo.RegistrationDate;

                    pdfList.Add(aPdfView);
                }
                GeneratePdf(pdfList, DateTime.Now.Date.ToString(), Session["username"].ToString());
            }
            return(RedirectToAction("Entry"));
        }
예제 #6
0
 private void GetItem()
 {
     UploadedFile = TextValue.Text.ToString();
     if (!string.IsNullOrWhiteSpace(UploadedFile))
     {
         PdfView.OpenFile(UploadedFile);
     }
 }
예제 #7
0
 private async void PDFView_InitializationCompletedHandlerAsync(PdfView sender, PSPDFKit.Pdf.Document document)
 {
     // If we already have a file to open lets proceed with that here.
     if (_fileToOpen != null)
     {
         await PDFView.OpenStorageFileAsync(_fileToOpen);
     }
     _pdfViewInitialised = true;
 }
예제 #8
0
        protected override ViewEngineResult FindView(ControllerContext context)
        {
            var result = base.FindView(context);
            if (result.View == null)
                return result;

            var pdfView = new PdfView(result);
            return new ViewEngineResult(pdfView, pdfView);
        }
예제 #9
0
 private void DiariesGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (DiariesGrid.SelectedIndex > -1)
     {
         DataRowView row = (DataRowView)DiariesGrid.SelectedItems[0];
         PdfView.OpenFile(row["UploadLocation"].ToString());
         UploadedFile = row["UploadLocation"].ToString();
     }
 }
예제 #10
0
        /// <summary>
        ///     Initializes the view model with the Pdf view. This is necessary as we have to trigger the search
        ///     from the view.
        /// </summary>
        /// <param name="pdfView">The Pdf view of the page</param>
        public void Initialize(PdfView pdfView)
        {
            PdfView      = pdfView;
            TextSearcher = new TextSearcher();

            PdfView.InitializationCompletedHandler += delegate {
                // We register the search result handler as soon as the Pdf view is initialized.
                TextSearcher.SearchResultHandler += APIOnSearchResultHandler;
            };
        }
예제 #11
0
        public void CGPdfPage()
        {
            TestRuntime.AssertXcodeVersion(9, 0);
            var pdfPath = NSBundle.MainBundle.PathForResource("Tamarin", "pdf");

            using var view = new PdfView();
            view.Document  = new PdfDocument(NSUrl.FromFilename(pdfPath));
            using var page = view.CurrentPage;
            Assert.IsNotNull(page.Page, "Page");
        }
예제 #12
0
 private void ChooseDiary_Click(object sender, RoutedEventArgs e)
 {
     FilePath = Repository.GetFile();
     if (FilePath != null)
     {
         string fullPath = Path.GetFullPath(FilePath);
         ChosenDiary.Text = Path.GetFileName(FilePath);
         PdfView.OpenFile(fullPath);
     }
 }
예제 #13
0
 private void Browse_Click(object sender, RoutedEventArgs e)
 {
     FilePath = Repository.GetFile();
     if (FilePath != null)
     {
         string fullPath = Path.GetFullPath(FilePath);
         SelectedDocument.Text = Path.GetFileName(FilePath);
         PdfView.OpenFile(fullPath);
         CheckExecutable();
     }
 }
예제 #14
0
        protected override ViewEngineResult FindView(ControllerContext context)
        {
            var result = base.FindView(context);

            if (result.View == null)
            {
                return(result);
            }

            var pdfView = new PdfView(result);

            return(new ViewEngineResult(pdfView, pdfView));
        }
        protected override void OnElementChanged(ElementChangedEventArgs <PDFView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                if (Control == null)
                {
                    _pdfView = new PdfView(Context, Element);
                    SetNativeControl(_pdfView);
                    LoadFile(Element?.Uri);
                }
            }
        }
예제 #16
0
 private void ChooseDiary_Click(object sender, RoutedEventArgs e)
 {
     FilePath = Repository.GetFile();
     if (FilePath != null)
     {
         string fullPath = Path.GetFullPath(FilePath);
         ChosenDiary.Text = Path.GetFileName(FilePath);
         PdfView.OpenFile(fullPath);
         if (!string.IsNullOrWhiteSpace(SelectedDiary.Text))
         {
             UploadDiary.IsEnabled = true;
         }
     }
 }
예제 #17
0
        internal void Initialize(PdfView pdfView)
        {
            PDFView = pdfView;

            // Register event handlers
            PDFView.InitializationCompletedHandler += PDFView_InitializationCompletedHandler;

            PDFView.OnDocumentOpened += (sender, document) => {
                Events.Add("Document Opened From " + (document.DocumentSource.GetFile() != null ? "StorageFile" : "IBuffer"));

                document.AnnotationsCreated += (view, annotations) => { AnnotationEvent("created", annotations); };
                document.AnnotationsDeleted += (view, annotations) => { AnnotationEvent("deleted", annotations); };
                document.AnnotationsUpdated += (view, annotations) => { AnnotationEvent("updated", annotations); };
            };
        }
        public void PrintPDF(NSUrl fileUrl)
        {
            // Create the print settings.
            ContentWebView.MainFrame.FrameView.PrintDocumentView();
            //printOperationWithPrintInfo: printInfo]

            NSPrintInfo sharePrintInfo = NSPrintInfo.SharedPrintInfo;
            var         sharedDict     = sharePrintInfo.Dictionary;

            NSMutableDictionary printInfoDict = NSMutableDictionary.FromDictionary(sharedDict);

            printInfoDict.Add(NSObject.FromObject("NSPrintHeaderAndFooter"), NSObject.FromObject(true));
            printInfoDict.Add(NSObject.FromObject("NSPrintJobDisposition"), NSObject.FromObject("NSPrintSpoolJob"));               //  NSPrintSaveJob

            var printInfo = new NSPrintInfo(printInfoDict);

            printInfo.TopMargin            = 72.0f;
            printInfo.BottomMargin         = 72.0f;
            printInfo.LeftMargin           = 0.0f;
            printInfo.RightMargin          = 0.0f;
            printInfo.HorizontalPagination = NSPrintingPaginationMode.Fit;
            printInfo.VerticalPagination   = NSPrintingPaginationMode.Auto;
            printInfo.HorizontallyCentered = true;
            printInfo.VerticallyCentered   = false;
            printInfo.ScalingFactor        = 0.5f;
            var rect = printInfo.ImageablePageBounds;
            // Create the document reference.
            var pdfData = ContentWebView.MainFrame.FrameView.DocumentView.DataWithPdfInsideRect(
                ContentWebView.MainFrame.FrameView.DocumentView.Frame);

            PdfDocument pdfDocument = new PdfDocument(pdfData);

            PdfView pdfView = new PdfView();

            pdfView.SetFrameSize(ContentWebView.MainFrame.FrameView.Frame.Size);
            pdfView.SetFrameOrigin(new CGPoint(0, 0));
            pdfView.Document = pdfDocument;

            var op = NSPrintOperation.FromView(pdfView.DocumentView, printInfo);

            op.ShowsProgressPanel = true;
            op.ShowsPrintPanel    = true;
            op.RunOperation();

            //op.RunOperationModal(View.Window,null);
        }
예제 #19
0
        private void SetLayout()
        {
            _pdfView = new PdfView();
            _pdfView.BackgroundColor = UIColor.White;
            Add(_pdfView);
            _pdfView.TranslatesAutoresizingMaskIntoConstraints = false;
            _pdfView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor).Active    = true;
            _pdfView.HeightAnchor.ConstraintEqualTo(View.HeightAnchor, new nfloat(0.8)).Active = true;
            _pdfView.WidthAnchor.ConstraintEqualTo(View.WidthAnchor).Active = true;

            _musicBar = new UIView();
            View.Add(_musicBar);
            _musicBar.BackgroundColor = new UIColor((nfloat)Xamarin.Forms.Color.FromHex("#343434").R, (nfloat)Xamarin.Forms.Color.FromHex("#343434").G, (nfloat)Xamarin.Forms.Color.FromHex("#343434").B, 1);
            _musicBar.TranslatesAutoresizingMaskIntoConstraints = false;
            _musicBar.TopAnchor.ConstraintEqualTo(_pdfView.BottomAnchor).Active = true;
            _musicBar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor).Active = true;
            _musicBar.WidthAnchor.ConstraintEqualTo(View.WidthAnchor).Active = true;
        }
예제 #20
0
        public PDFViewPage()
        {
            InitializeComponent();
            Pdfview = PDFView;

            PDFView.OnSuspendUnloading += (sender, args) =>
            {
                // Reset the displated document.
                // This is a work aronud to ensure that if the user navigates away from
                // the Page and then back, a document will still be shown.
                _fileToOpen = null;
            };

            PDFView.OnDocumentOpened += (pdfView, document) =>
            {
                document.AnnotationsCreated += DocumentOnAnnotationsCreated;
                document.AnnotationsUpdated += DocumentOnAnnotationsUpdated;
                document.AnnotationsDeleted += DocumentOnAnnotationsDeleted;
            };
        }
예제 #21
0
        async void PDFView_InitializationCompletedHandler(PdfView pdfView, Document document)
        {
            pdfView.Controller.OnPrint += (sender, args) => { Events.Add("Print Button Clicked"); };
            pdfView.Controller.OnCurrentPageChanged += (sender, pageIndex) => {
                Events.Add($"Current Page Changed to {pageIndex}");
            };

            pdfView.Controller.OnAnnotationSelectionChanged += (sender, annotation) => {
                if (annotation == null)
                {
                    Events.Add("No annotation selected");
                }
                else
                {
                    Events.Add($"Selected {annotation.AnnotationType.ToString ()} annotation with {annotation.Id}");
                }
            };

            var pageCount = await document.GetTotalPageCountAsync();

            Events.Add($"PdfView Initialization Completed: Opened document with {pageCount} pages");
        }
        public ActionResult Entry(MovementEntryVM movementM)
        {
            var username = Session["username"].ToString();
            int orgid    = 0;
            var list     = userManager.GetAll().Where(c => c.UserName == username);

            foreach (var t in list)
            {
                orgid = t.OrganizationId;
            }

            ViewBag.orglist = organizationManager.GetAll();
            MovementEntryVM model = new MovementEntryVM()
            {
                OrganizationLookUp = loader.GetOrganizationByUserOrgIdSelectitems(orgid),
                //AssetLookUp = loader.GetAssetSelectListItems()
                AssetLookUp = loader.GetAssetSelectListItemsJoinwithAssetDetails(orgid)
            };

            string format = "d";

            model.RegistrationDate = DateTime.Today.ToString(format);
            List <MovementEntryVM> aList = (List <MovementEntryVM>)Session["CartList"];

            if (aList != null && aList.Any())
            {
                List <PdfView> pdfList = new List <PdfView>();
                foreach (var mo in aList)
                {
                    MovementEntryVM movementVM = new MovementEntryVM();
                    movementVM = mo;

                    movementVM.MoveBy = Session["username"].ToString();
                    AssetRegistrationDetails details = assetdetailsmanager.GetIdAssetId(movementVM.AssetId);
                    int detailsId = details.Id;
                    details = assetdetailsmanager.GetById(detailsId);
                    details.OrganizationId = movementVM.OrganizationId;
                    details.BranchId       = movementVM.OrganizationId;

                    var movement = Mapper.Map <Movement>(movementVM);

                    MovementPermision mvp = new MovementPermision();
                    mvp.Permision = false;
                    var  movementPermision = Mapper.Map <MovementPermision>(movementVM);
                    bool isSaved;
                    if (Session["Designation"].ToString() == "Manager")
                    {
                        isSaved = movementPermisionManager.Add(movementPermision);
                    }
                    else
                    {
                        isSaved = movementManager.Add(movement);
                    }



                    if (isSaved)
                    {
                        details.BranchId = movementVM.BranchId;
                        if (assetdetailsmanager.Update(details))
                        {
                            ModelState.Clear();
                            ViewBag.message = "Save Successfully";



                            PdfView aPdfView = new PdfView();

                            aPdfView.OrganizationId   = movement.OrganizationId;
                            aPdfView.OrganizationName = movement.OrganizationName;
                            aPdfView.AssetId          = movement.AssetId;
                            aPdfView.AssecCode        = movementVM.Code;
                            aPdfView.AssetSerialNo    = movementVM.SerialNo;
                            aPdfView.GeneralCategory  = movementVM.GeneralCategoryName;
                            aPdfView.Category         = movementVM.CategoryNme;
                            aPdfView.Brand            = movementVM.BrandName;
                            aPdfView.FromBranch       = movement.BranchName;
                            aPdfView.ToBranch         = branchManager.GetById(movement.BranchId).Name;
                            aPdfView.MovedBy          = movement.MoveBy;
                            aPdfView.Date             = movement.RegistrationDate;

                            pdfList.Add(aPdfView);
                        }
                    }
                }

                GeneratePdf(pdfList, DateTime.Now.Date.ToString(), Session["username"].ToString());
                Session["Printed"] = "YES";
            }

            return(RedirectToAction("Entry"));
        }
 public DefaultLinkHandler(PdfView pdfView)
 {
     this.pdfView = pdfView;
 }
 public void Initialize(int cIsso)
 {
     PdfView.Initialize(cIsso);
 }
 public void Initialize(PdfView pdfView)
 {
     PDFView = pdfView;
     PDFView.ShowMessage("Password is 'pspdfkit'.");
 }
 public override void Dispose()
 {
     PdfView.Dispose();
 }
예제 #27
0
 // Once the Document is initialized we tell it we want to know when the user clicks the print button
 private void PDFView_InitializationCompletedHandler(PdfView sender, Document document) => sender.Controller.OnPrint += API_OnPrint;
예제 #28
0
        private async void PDFView_InitializationCompletedHandlerAsync(PdfView sender, PSPDFKit.Pdf.Document args)
        {
            await PDFView.Controller.ShowDocumentWithViewStateAsync(DocumentSource.CreateFromStorageFile(_fileToOpen), _viewStateCache);

            _pdfViewInitialised = true;
        }
예제 #29
0
 public void Initialize(PdfView pdfView) => PDFView = pdfView;
예제 #30
0
 private void btnSave_as_PDF_Click(object sender, RibbonControlEventArgs e)
 {
     PdfView pdfview = new PdfView();
 }
 void ExecuteOpenManualCommand()
 {
     var win = new PdfView();
 }