public LinkEditorViewController(PSPDFDocument document) : base(document) { Document.EditableAnnotationTypes = new NSOrderedSet ( (NSObject) PSPDFAnnotationString.Link, // Important!! (NSObject) PSPDFAnnotationString.Highlight, (NSObject) PSPDFAnnotationString.Underline, (NSObject) PSPDFAnnotationString.Squiggly, (NSObject) PSPDFAnnotationString.StrikeOut, (NSObject) PSPDFAnnotationString.Note, (NSObject) PSPDFAnnotationString.FreeText, (NSObject) PSPDFAnnotationString.Ink, (NSObject) PSPDFAnnotationString.Square, (NSObject) PSPDFAnnotationString.Circle, (NSObject) PSPDFAnnotationString.Stamp ); }
public DropboxPDFViewController(PSPDFDocument document) : base(document) { PageTransition = PSPDFPageTransition.ScrollContinuous; ScrollDirection = PSPDFScrollDirection.Vertical; StatusBarStyleSetting = PSPDFStatusBarStyle.Default; ShouldHideStatusBarWithHUD = false; RenderAnimationEnabled = false; ThumbnailBarMode = PSPDFThumbnailBarMode.None; ThumbnailController.FilterOptions = null; OutlineButtonItem.AvailableControllerOptions = new NSOrderedSet (PSPDFOutlineBarButtonItemOption.Outline); LeftBarButtonItems = null; RightBarButtonItems = null; Title = document.Title; DocumentLabelEnabled = false; DidChangeViewMode += (o, s) => UpdateFloatingToolbarAnimated (true); }
public PlayGroundViewController(PSPDFDocument document) : base(document) { }
public static void RegisterOverrideClasses(NSKeyedUnarchiver unarchiver, PSPDFDocument document) { _RegisterOverrideClasses (unarchiver.Handle, document.Handle); }
public PSPDFDocumentProvider(CGDataProvider dataProvider, PSPDFDocument document) : this(dataProvider.Handle, document) { }
public PSPDFTextParser(CGPDFPage pageRef, uint page, PSPDFDocument document, NSMutableDictionary fontCache, bool hideGlyphsOutsidePageRect, CGPDFBox pdfBox) : this(pageRef.Handle, page, document, fontCache, hideGlyphsOutsidePageRect, pdfBox) { }
public DVCMenu() : base(UITableViewStyle.Grouped, null) { Root = new RootElement ("PSPDFKit") { new Section (PSPDFKitGlobal.VersionString){ new StringElement ("PSPDFViewController playground", () => { var pdfViewer = new PlayGroundViewController (NSUrl.FromFilename (HackerMonthlyFile)); NavigationController.PushViewController (pdfViewer, true); }) }, new Section ("Annotations"){ new StringElement ("Annotations From Code", () => { // we use a NSData document here but it'll work even better with a file-based variant. NSError err; var documentData = NSData.FromUrl (NSUrl.FromFilename (HackerMonthlyFile), NSDataReadingOptions.Mapped, out err); var pdfViewer = new AnnotationsFromCodeViewController (documentData); NavigationController.PushViewController (pdfViewer, true); }) }, new Section ("Interface"){ new StringElement ("Dropbox-like interface", () => { var document = new PSPDFDocument (NSUrl.FromFilename (HackerMonthlyFile)); var pdfViewer = new DropboxPDFViewController (document); NavigationController.PushViewController (pdfViewer, true); }) }, new Section ("Password / Security", "Password is: test123") { new StringElement ("Password Preset", () => { var document = new PSPDFDocument (NSUrl.FromFilename (ProtectedFile)); document.UnlockWithPassword ("test123"); var pdfViewer = new PSPDFViewController (document); NavigationController.PushViewController (pdfViewer, true); }), new StringElement ("Password Not Preset", () => { var document = new PSPDFDocument (NSUrl.FromFilename (ProtectedFile)); var pdfViewer = new PSPDFViewController (document); NavigationController.PushViewController (pdfViewer, true); }), new StringElement ("Create Password Protected PDF", () => { var document = new PSPDFDocument (NSUrl.FromFilename (HackerMonthlyFile)); var status = PSPDFStatusHUDItem.GetProgressItem ("Preparing"); status.Push (true); // Create temp file and password var tempPdf = NSUrl.FromFilename (Path.Combine (Path.GetTempPath (), Guid.NewGuid ().ToString () + ".pdf")); var password = new NSString ("test123"); // Lets create the dictionary options needed by the PSPDFProcesor // With password protected pages, PSPDFProcessor can only add link annotations. // We use a helper class to access the CGPDFContextKeys used by the dictionary var processorOptions = new NSMutableDictionary (); processorOptions.LowlevelSetObject (password, Helper.CGPDFContextUserPassword); processorOptions.LowlevelSetObject (password, Helper.CGPDFContextOwnerPassword); processorOptions.LowlevelSetObject (NSNumber.FromInt32 (128), Helper.CGPDFContextEncryptionKeyLength); processorOptions.LowlevelSetObject (NSNumber.FromBoolean (true), PSPDFProcessorOptionKeys.AnnotationAsDictionary.Handle); processorOptions.LowlevelSetObject (NSNumber.FromObject (PSPDFAnnotationType.Link), PSPDFProcessorOptionKeys.AnnotationTypes.Handle); // We create the page range we want to include in our pdf var pageRange = new [] { NSIndexSet.FromNSRange (new NSRange (0, (int)document.PageCount)) }; // We start a new task so this executes on a separated thread since it is a hevy task and we don't want to block the UI Task.Factory.StartNew (()=> { NSError err; PSPDFProcessor.DefaultProcessor.GeneratePDFFromDocument (document: document, pageRange: pageRange, fileURL: tempPdf, options: (NSDictionary) processorOptions, progressHandler: (currentPage, numberOfProcessedPages, totalPages) => InvokeOnMainThread (()=> status.Progress = ((float)numberOfProcessedPages / (float)totalPages)), error: out err); }).ContinueWith ((task) => { InvokeOnMainThread (()=> { status.Pop (true); var docToShow = new PSPDFDocument (tempPdf); var pdfViewer = new PSPDFViewController (docToShow); NavigationController.PushViewController (pdfViewer, true); }); }); }), }, new Section ("Subclassing", "Examples how to subclass PSPDFKit."){ new StringElement ("Annotation Link Editor", () => { var document = new PSPDFDocument (NSUrl.FromFilename (HackerMonthlyFile)); // Need to cast to solve ambiguity between NSObject and string ctor document.EditableAnnotationTypes = new NSOrderedSet ( (NSObject) PSPDFAnnotationString.Link, // Important!! (NSObject) PSPDFAnnotationString.Highlight, (NSObject) PSPDFAnnotationString.Underline, (NSObject) PSPDFAnnotationString.Squiggly, (NSObject) PSPDFAnnotationString.StrikeOut, (NSObject) PSPDFAnnotationString.Note, (NSObject) PSPDFAnnotationString.FreeText, (NSObject) PSPDFAnnotationString.Ink, (NSObject) PSPDFAnnotationString.Square, (NSObject) PSPDFAnnotationString.Circle, (NSObject) PSPDFAnnotationString.Stamp ); var pdfViewer = new LinkEditorViewController (document); NavigationController.PushViewController (pdfViewer, true); }), new StringElement ("Capture Bookmarks", () => { var document = new PSPDFDocument (NSUrl.FromFilename (HackerMonthlyFile)); document.OverrideClass (new Class (typeof (PSPDFBookmarkParser)), new Class (typeof (CustomBookmarkParser))); var pdfViewer = new PSPDFViewController (document); pdfViewer.RightBarButtonItems = new NSObject[] { pdfViewer.BookmarkButtonItem, pdfViewer.SearchButtonItem, pdfViewer.OutlineButtonItem, pdfViewer.ViewModeButtonItem }; NavigationController.PushViewController (pdfViewer, true); }), new StringElement ("Change link background color to red", () => { var document = new PSPDFDocument (NSUrl.FromFilename (HackerMonthlyFile)); // Note: You can also globally change the color using: // PSPDFLinkAnnotationView.SetGlobalBorderColor = UIColor.Green; // We don't use this in the example here since it would change the color globally for all examples. var pdfViewer = new PSPDFViewController (document); pdfViewer.OverrideClass (new Class (typeof (PSPDFLinkAnnotationView)), new Class (typeof (CustomLinkAnnotationView))); NavigationController.PushViewController (pdfViewer, true); }), new StringElement ("Custom AnnotationProvider", () => { var document = new PSPDFDocument (NSUrl.FromFilename (HackerMonthlyFile)); document.SetDidCreateDocumentProviderBlock ((documentProvider)=> { documentProvider.AnnotationManager.AnnotationProviders = new NSObject[] { new CustomAnnotationProvider ((int)documentProvider.Document.PageCount), documentProvider.AnnotationManager.FileAnnotationProvider }; }); var pdfViewer = new PSPDFViewController (document); NavigationController.PushViewController (pdfViewer, true); }) }, }; }
public ViewerPageController(PSPDFDocument document) : base(document) { document.Title = document.FileName.Replace (".pdf", ""); }
public void OpenPDF(LibraryType DocumentType, string MediaURL, string FileName, int NavigationRoot = 0, Action<bool> completed = null) { UIWindow window = UIApplication.SharedApplication.KeyWindow; var uid = MediaURL.Substring (MediaURL.LastIndexOf ("/") + 1, MediaURL.Length - 1 - MediaURL.LastIndexOf ("/")).Replace (".pdf", "") + FileName; if (DocumentType == LibraryType.NewsLetter) { PSPDFDocument document; if (!MediaURL.StartsWith ("http")) { var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments); var directoryname = Path.Combine (documents, "Downloads"); MediaURL = Path.Combine (directoryname, MediaURL); document = new PSPDFDocument (NSUrl.FromFilename (new Uri (MediaURL).ToString ())); } else { document = new PSPDFDocument (NSUrl.FromString (MediaURL)); } document.Uid = uid; var pdfViewer = new ViewerPageController (document); var rootController = window.RootViewController.ChildViewControllers [0].ChildViewControllers [2]; var navcontroller = rootController as UINavigationController; if (navcontroller != null) { pdfViewer.HidesBottomBarWhenPushed = true; navcontroller.PushViewController (pdfViewer, true); } } else if (DocumentType == LibraryType.MyDocuments) { var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments); var directoryname = Path.Combine (documents, "Downloads"); var path = Path.Combine (directoryname, MediaURL); var document = new PSPDFDocument (NSUrl.FromFilename (new Uri (path).ToString ())); document.Uid = uid; var pdfViewer = new ViewerPageController (document); var rootController = window.RootViewController.ChildViewControllers [0].ChildViewControllers [3]; var navcontroller = rootController as UINavigationController; if (navcontroller != null) { pdfViewer.HidesBottomBarWhenPushed = true; navcontroller.PushViewController (pdfViewer, true); } } else if (DocumentType == LibraryType.Search) { PSPDFDocument document; if (!MediaURL.StartsWith ("http")) { var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments); var directoryname = Path.Combine (documents, "Downloads"); MediaURL = Path.Combine (directoryname, MediaURL); document = new PSPDFDocument (NSUrl.FromFilename (new Uri (MediaURL).ToString ())); } else { document = new PSPDFDocument (NSUrl.FromString (MediaURL)); } document.Uid = uid; var pdfViewer = new ViewerPageController (document); var rootController = window.RootViewController.ChildViewControllers [0].ChildViewControllers [NavigationRoot]; var navcontroller = rootController as UINavigationController; if (navcontroller != null) { pdfViewer.HidesBottomBarWhenPushed = true; navcontroller.PushViewController (pdfViewer, true); } } else { PSPDFDocument document; if (!MediaURL.StartsWith ("http")) { var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments); var directoryname = Path.Combine (documents, "Downloads"); MediaURL = Path.Combine (directoryname, MediaURL); document = new PSPDFDocument (NSUrl.FromFilename (new Uri (MediaURL).ToString ())); } else { document = new PSPDFDocument (NSUrl.FromString (MediaURL)); } document.Uid = uid; var pdfViewer = new ViewerPageController (document); var rootController = window.RootViewController.ChildViewControllers [0].ChildViewControllers [1]; var navcontroller = rootController as UINavigationController; if (navcontroller != null) { pdfViewer.HidesBottomBarWhenPushed = true; navcontroller.PushViewController (pdfViewer, true); } } }
public PSCSimpleDrawingPDFViewController(PSPDFDocument document) : base(document) { }