Platforms to show: All Mac Windows Linux Cross-Platform
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /PDFKit/PDFView iOS Test
This example is the version from Mon, 10th Sep 2023.
Project "PDFView iOS Test.xojo_binary_project"
Class App Inherits MobileApplication
End Class
Class PhoneScreen Inherits MobileScreen
Control PDFView Inherits PDFViewIOSControlMBS
ControlInstance PDFView Inherits PDFViewIOSControlMBS
Constraint Constraint 1
Constraint Constraint 2
Constraint Constraint 3
Constraint Constraint 4
End Control
EventHandler Sub Opening()
Dim item As FolderItem = SpecialFolder.Resource("Castles.pdf")
LoadPDF item
// you can listen for a lot of notifications
ListenForNotification PDFViewMBS.PDFViewAnnotationHitNotification
ListenForNotification PDFViewMBS.PDFViewAnnotationWillHitNotification
ListenForNotification PDFViewMBS.PDFViewChangedHistoryNotification
ListenForNotification PDFViewMBS.PDFViewCopyPermissionNotification
ListenForNotification PDFViewMBS.PDFViewDisplayBoxChangedNotification
ListenForNotification PDFViewMBS.PDFViewDisplayModeChangedNotification
ListenForNotification PDFViewMBS.PDFViewDocumentChangedNotification
ListenForNotification PDFViewMBS.PDFViewPageChangedNotification
ListenForNotification PDFViewMBS.PDFViewPrintPermissionNotification
ListenForNotification PDFViewMBS.PDFViewScaleChangedNotification
ListenForNotification PDFViewMBS.PDFViewSelectionChangedNotification
ListenForNotification PDFViewMBS.PDFViewVisiblePagesChangedNotification
End EventHandler
Sub ListenForNotification(NotificationName as string)
Dim o As New NSNotificationObserverMBS
Static c As NSNotificationCenterMBS = NSNotificationCenterMBS.defaultCenter
AddHandler o.GotNotification, WeakAddressOf NotificationReceived
c.addObserver o, NotificationName, PDFView.View
observers.append o
End Sub
Sub LoadPDF(item as FolderItem)
Dim d As New PDFDocumentMBS(item)
If d.pageCount < 1 Then Return // error?
Self.Title = item.Name
Dim v As PDFViewMBS = PDFView.View
v.displaysPageBreaks = True
v.autoScales = True
v.backgroundColor = NSColorMBS.grayColor
v.displayMode = v.kPDFDisplaySinglePage
v.document = d
End Sub
Sub NotificationReceived(n as NSNotificationObserverMBS, Notification as NSNotificationMBS)
System.DebugLog "Received: " + Notification.Name
Dim info As Dictionary = Notification.userInfo
If Notification.Name = PDFViewMBS.PDFViewAnnotationHitNotification Then
Dim annotation As PDFAnnotationMBS = info.Value("PDFAnnotationHit")
Break
End If
End Sub
Property observers() As NSNotificationObserverMBS
End Class
Class LaunchScreen Inherits iosView
End Class
Class PadScreen Inherits MobileScreen
Control PDFThumbnailView Inherits PDFThumbnailViewIOSControlMBS
ControlInstance PDFThumbnailView Inherits PDFThumbnailViewIOSControlMBS
Constraint Constraint 1
Constraint Constraint 2
Constraint Constraint 3
Constraint Constraint 4
Constraint Constraint 5
End Control
Control PDFView Inherits PDFViewIOSControlMBS
ControlInstance PDFView Inherits PDFViewIOSControlMBS
Constraint Constraint 1
Constraint Constraint 2
Constraint Constraint 3
Constraint Constraint 4
End Control
EventHandler Sub Opening()
Dim item As FolderItem = SpecialFolder.Resource("Castles.pdf")
LoadPDF item
// you can listen for a lot of notifications
ListenForNotification PDFViewMBS.PDFViewAnnotationHitNotification
ListenForNotification PDFViewMBS.PDFViewAnnotationWillHitNotification
ListenForNotification PDFViewMBS.PDFViewChangedHistoryNotification
ListenForNotification PDFViewMBS.PDFViewCopyPermissionNotification
ListenForNotification PDFViewMBS.PDFViewDisplayBoxChangedNotification
ListenForNotification PDFViewMBS.PDFViewDisplayModeChangedNotification
ListenForNotification PDFViewMBS.PDFViewDocumentChangedNotification
ListenForNotification PDFViewMBS.PDFViewPageChangedNotification
ListenForNotification PDFViewMBS.PDFViewPrintPermissionNotification
ListenForNotification PDFViewMBS.PDFViewScaleChangedNotification
ListenForNotification PDFViewMBS.PDFViewSelectionChangedNotification
ListenForNotification PDFViewMBS.PDFViewVisiblePagesChangedNotification
End EventHandler
Sub ListenForNotification(NotificationName as string)
Dim o As New NSNotificationObserverMBS
Static c As NSNotificationCenterMBS = NSNotificationCenterMBS.defaultCenter
AddHandler o.GotNotification, WeakAddressOf NotificationReceived
c.addObserver o, NotificationName, PDFView.View
observers.append o
End Sub
Sub LoadPDF(item as FolderItem)
Dim d As New PDFDocumentMBS(item)
If d.pageCount < 1 Then Return // error?
Self.Title = item.Name
Dim v As PDFViewMBS = PDFView.View
v.displaysPageBreaks = True
v.autoScales = True
v.displayMode = v.kPDFDisplaySinglePage
v.document = d
v.backgroundColor = NSColorMBS.grayColor
Dim t As PDFThumbnailViewMBS = PDFThumbnailView.View
t.PDFView = v
t.backgroundColor = NSColorMBS.lightGrayColor
t.thumbnailSize = new NSSizeMBS(200,300)
End Sub
Sub NotificationReceived(n as NSNotificationObserverMBS, Notification as NSNotificationMBS)
System.DebugLog "Received: " + Notification.Name
Dim info As Dictionary = Notification.userInfo
If Notification.Name = PDFViewMBS.PDFViewAnnotationHitNotification Then
Dim annotation As PDFAnnotationMBS = info.Value("PDFAnnotationHit")
Break
End If
End Sub
Property observers() As NSNotificationObserverMBS
End Class
End Project
The items on this page are in the following plugins: MBS PDFKit Plugin.