diff --git a/src/pdfkit.cs b/src/pdfkit.cs index 869ebffc75bd..0db5320ab46c 100644 --- a/src/pdfkit.cs +++ b/src/pdfkit.cs @@ -31,6 +31,9 @@ #if MONOMAC using AppKit; using UIViewController = Foundation.NSObject; +using UIFindInteraction = Foundation.NSObject; +using UIFindInteractionDelegate = Foundation.NSObject; +using UIView = AppKit.NSView; #else using UIKit; using NSColor = UIKit.UIColor; @@ -49,6 +52,7 @@ using Foundation; using ObjCRuntime; using CoreGraphics; +using System.ComponentModel; #if !NET using NativeHandle = System.IntPtr; @@ -403,6 +407,31 @@ interface PdfDocumentAttributeKeys { NSString KeywordsKey { get; } } + [Mac (13,0), iOS (16,0), MacCatalyst (16,0)] + [StrongDictionary ("PdfPageImageInitializationOptionKeys")] + interface PdfPageImageInitializationOption { + CGRect MediaBox { get; set; } + int Rotation { get; set; } + bool UpscaleIfSmaller { get; set; } + double CompressionQuality { get; set; } + } + + [Mac (13,0), iOS (16,0), MacCatalyst (16,0)] + [Static] + interface PdfPageImageInitializationOptionKeys { + [Field ("PDFPageImageInitializationOptionMediaBox")] + NSString MediaBoxKey { get; } + + [Field ("PDFPageImageInitializationOptionRotation")] + NSString RotationKey { get; } + + [Field ("PDFPageImageInitializationOptionUpscaleIfSmaller")] + NSString UpscaleIfSmallerKey { get; } + + [Field ("PDFPageImageInitializationOptionCompressionQuality")] + NSString CompressionQualityKey { get; } + } + [iOS (11,0)] [StrongDictionary ("PdfDocumentAttributeKeys")] interface PdfDocumentAttributes { @@ -432,6 +461,14 @@ interface PdfDocumentWriteOptionKeys { [iOS (15,0), Mac (12,0), MacCatalyst (15,0)] [Field ("PDFDocumentAccessPermissionsOption", "+PDFKit")] NSString AccessPermissionsKey { get; } + + [iOS (16,0), Mac (13,0), MacCatalyst (16,0)] + [Field ("PDFDocumentBurnInAnnotationsOption", "+PDFKit")] + NSString BurnInAnnotationsKey { get; } + + [iOS (16,0), Mac (13,0), MacCatalyst (16,0)] + [Field ("PDFDocumentSaveTextFromOCROption", "+PDFKit")] + NSString SaveTextFromOcrKey { get; } } [Mac (10,13)] @@ -1524,10 +1561,19 @@ interface PdfPage : NSCopying { [DesignatedInitializer] NativeHandle Constructor (); - [DesignatedInitializer] [Export ("initWithImage:")] NativeHandle Constructor (NSImage image); + [EditorBrowsable (EditorBrowsableState.Advanced)] + [Mac (13,0), iOS (16,0), MacCatalyst (16,0)] + [DesignatedInitializer] + [Export ("initWithImage:options:")] + NativeHandle Constructor (NSImage image, NSDictionary options); + + [Mac (13,0), iOS (16,0), MacCatalyst (16,0)] + [Wrap ("this (image, options.GetDictionary ()!)")] + NativeHandle Constructor (NSImage image, PdfPageImageInitializationOption options); + [Export ("document"), NullAllowed] PdfDocument Document { get; } @@ -1743,7 +1789,7 @@ interface PdfThumbnailView : NSCoding { [BaseType (typeof (NSView), Name = "PDFView", Delegates = new string [] { "WeakDelegate" }, Events = new Type [] { typeof (PdfViewDelegate) })] interface PdfView : #if IOS - UIGestureRecognizerDelegate + UIGestureRecognizerDelegate, UIFindInteractionDelegate #else NSMenuDelegate, NSAnimationDelegate #endif @@ -2065,6 +2111,22 @@ interface PdfView : [Mac (10,13)] [Export ("acceptsDraggedFiles")] bool AcceptsDraggedFiles { get; set; } + + [iOS (16,0), Mac (13,0), MacCatalyst (16,0)] + [NullAllowed, Export ("pageOverlayViewProvider", ArgumentSemantic.Weak)] + IPdfPageOverlayViewProvider PageOverlayViewProvider { get; set; } + + [iOS (16,0), Mac (13,0), MacCatalyst (16,0)] + [Export ("inMarkupMode")] + bool InMarkupMode { [Bind ("isInMarkupMode")] get; set; } + + [iOS (16,0), NoMac, MacCatalyst (16,0)] + [Export ("findInteraction")] + UIFindInteraction FindInteraction { get; } + + [iOS (16,0), NoMac, MacCatalyst (16,0)] + [Export ("findInteractionEnabled")] + bool FindInteractionEnabled { [Bind ("isFindInteractionEnabled")] get; set; } } [NoiOS] @@ -2118,4 +2180,22 @@ interface PdfViewDelegate { UIViewController ParentViewController { get; } } + [Mac (13,0), iOS (16,0), MacCatalyst (16,0)] + interface IPdfPageOverlayViewProvider {} + + [Mac (13,0), iOS (16,0), MacCatalyst (16,0)] + [Protocol (Name = "PDFPageOverlayViewProvider")] + interface PdfPageOverlayViewProvider + { + [Abstract] + [Export ("pdfView:overlayViewForPage:")] + [return: NullAllowed] + UIView GetOverlayView (PdfView view, PdfPage page); + + [Export ("pdfView:willDisplayOverlayView:forPage:")] + void WillDisplayOverlayView (PdfView pdfView, UIView overlayView, PdfPage page); + + [Export ("pdfView:willEndDisplayingOverlayView:forPage:")] + void WillEndDisplayingOverlayView (PdfView pdfView, UIView overlayView, PdfPage page); + } } diff --git a/src/uikit.cs b/src/uikit.cs index d931b153cae4..0e59a1921c7a 100644 --- a/src/uikit.cs +++ b/src/uikit.cs @@ -25258,7 +25258,7 @@ interface UIPasteControlConfiguration : NSSecureCoding interface IUIFindInteractionDelegate {} - [NoWatch, NoTV, iOS (16,0), MacCatalyst (16,0)] + [NoWatch, NoTV, iOS (16,0), MacCatalyst (16,0), NoMac] #if NET [Protocol, Model] #else @@ -25267,6 +25267,11 @@ interface IUIFindInteractionDelegate {} [BaseType (typeof(NSObject))] interface UIFindInteractionDelegate { + // This abstract method needs attributes since PDFKit.PDFView + // implements this interface and has iOS 11 support. When inlining + // this method, the attributes are not carried over and causes issues + // since it is not supported until iOS 16 + [NoWatch, NoTV, iOS (16,0), MacCatalyst (16,0), NoMac] [Abstract] [Export ("findInteraction:sessionForView:")] [return: NullAllowed] diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-PDFKit.todo b/tests/xtro-sharpie/api-annotations-dotnet/iOS-PDFKit.todo deleted file mode 100644 index b54ad0180732..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/iOS-PDFKit.todo +++ /dev/null @@ -1,17 +0,0 @@ -!missing-protocol-conformance! PDFView should conform to UIFindInteractionDelegate -!missing-selector! PDFView::findInteraction not bound -!missing-selector! PDFView::isFindInteractionEnabled not bound -!missing-selector! PDFView::isInMarkupMode not bound -!missing-selector! PDFView::pageOverlayViewProvider not bound -!missing-selector! PDFView::setFindInteractionEnabled: not bound -!missing-selector! PDFView::setInMarkupMode: not bound -!missing-selector! PDFView::setPageOverlayViewProvider: not bound -!missing-field! PDFDocumentBurnInAnnotationsOption not bound -!missing-field! PDFDocumentSaveTextFromOCROption not bound -!missing-protocol! PDFPageOverlayViewProvider not bound -!extra-designated-initializer! PDFPage::initWithImage: is incorrectly decorated with an [DesignatedInitializer] attribute -!missing-field! PDFPageImageInitializationOptionCompressionQuality not bound -!missing-field! PDFPageImageInitializationOptionMediaBox not bound -!missing-field! PDFPageImageInitializationOptionRotation not bound -!missing-field! PDFPageImageInitializationOptionUpscaleIfSmaller not bound -!missing-selector! PDFPage::initWithImage:options: not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-PDFKit.todo b/tests/xtro-sharpie/api-annotations-dotnet/macOS-PDFKit.todo deleted file mode 100644 index ea2fb00c9264..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-PDFKit.todo +++ /dev/null @@ -1,13 +0,0 @@ -!missing-selector! PDFView::isInMarkupMode not bound -!missing-selector! PDFView::pageOverlayViewProvider not bound -!missing-selector! PDFView::setInMarkupMode: not bound -!missing-selector! PDFView::setPageOverlayViewProvider: not bound -!missing-field! PDFDocumentBurnInAnnotationsOption not bound -!missing-field! PDFDocumentSaveTextFromOCROption not bound -!missing-protocol! PDFPageOverlayViewProvider not bound -!extra-designated-initializer! PDFPage::initWithImage: is incorrectly decorated with an [DesignatedInitializer] attribute -!missing-field! PDFPageImageInitializationOptionCompressionQuality not bound -!missing-field! PDFPageImageInitializationOptionMediaBox not bound -!missing-field! PDFPageImageInitializationOptionRotation not bound -!missing-field! PDFPageImageInitializationOptionUpscaleIfSmaller not bound -!missing-selector! PDFPage::initWithImage:options: not bound diff --git a/tests/xtro-sharpie/iOS-PDFKit.todo b/tests/xtro-sharpie/iOS-PDFKit.todo deleted file mode 100644 index b54ad0180732..000000000000 --- a/tests/xtro-sharpie/iOS-PDFKit.todo +++ /dev/null @@ -1,17 +0,0 @@ -!missing-protocol-conformance! PDFView should conform to UIFindInteractionDelegate -!missing-selector! PDFView::findInteraction not bound -!missing-selector! PDFView::isFindInteractionEnabled not bound -!missing-selector! PDFView::isInMarkupMode not bound -!missing-selector! PDFView::pageOverlayViewProvider not bound -!missing-selector! PDFView::setFindInteractionEnabled: not bound -!missing-selector! PDFView::setInMarkupMode: not bound -!missing-selector! PDFView::setPageOverlayViewProvider: not bound -!missing-field! PDFDocumentBurnInAnnotationsOption not bound -!missing-field! PDFDocumentSaveTextFromOCROption not bound -!missing-protocol! PDFPageOverlayViewProvider not bound -!extra-designated-initializer! PDFPage::initWithImage: is incorrectly decorated with an [DesignatedInitializer] attribute -!missing-field! PDFPageImageInitializationOptionCompressionQuality not bound -!missing-field! PDFPageImageInitializationOptionMediaBox not bound -!missing-field! PDFPageImageInitializationOptionRotation not bound -!missing-field! PDFPageImageInitializationOptionUpscaleIfSmaller not bound -!missing-selector! PDFPage::initWithImage:options: not bound diff --git a/tests/xtro-sharpie/macOS-PDFKit.todo b/tests/xtro-sharpie/macOS-PDFKit.todo deleted file mode 100644 index ea2fb00c9264..000000000000 --- a/tests/xtro-sharpie/macOS-PDFKit.todo +++ /dev/null @@ -1,13 +0,0 @@ -!missing-selector! PDFView::isInMarkupMode not bound -!missing-selector! PDFView::pageOverlayViewProvider not bound -!missing-selector! PDFView::setInMarkupMode: not bound -!missing-selector! PDFView::setPageOverlayViewProvider: not bound -!missing-field! PDFDocumentBurnInAnnotationsOption not bound -!missing-field! PDFDocumentSaveTextFromOCROption not bound -!missing-protocol! PDFPageOverlayViewProvider not bound -!extra-designated-initializer! PDFPage::initWithImage: is incorrectly decorated with an [DesignatedInitializer] attribute -!missing-field! PDFPageImageInitializationOptionCompressionQuality not bound -!missing-field! PDFPageImageInitializationOptionMediaBox not bound -!missing-field! PDFPageImageInitializationOptionRotation not bound -!missing-field! PDFPageImageInitializationOptionUpscaleIfSmaller not bound -!missing-selector! PDFPage::initWithImage:options: not bound