objc2-pdf-kit 0.3.2

Bindings to the PDFKit framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-graphics")]
use objc2_core_graphics::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfprintscalingmode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PDFPrintScalingMode(pub NSInteger);
impl PDFPrintScalingMode {
    #[doc(alias = "kPDFPrintPageScaleNone")]
    pub const PageScaleNone: Self = Self(0);
    #[doc(alias = "kPDFPrintPageScaleToFit")]
    pub const PageScaleToFit: Self = Self(1);
    #[doc(alias = "kPDFPrintPageScaleDownToFit")]
    pub const PageScaleDownToFit: Self = Self(2);
}

unsafe impl Encode for PDFPrintScalingMode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for PDFPrintScalingMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentpermissions?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PDFDocumentPermissions(pub NSInteger);
impl PDFDocumentPermissions {
    #[doc(alias = "kPDFDocumentPermissionsNone")]
    pub const None: Self = Self(0);
    #[doc(alias = "kPDFDocumentPermissionsUser")]
    pub const User: Self = Self(1);
    #[doc(alias = "kPDFDocumentPermissionsOwner")]
    pub const Owner: Self = Self(2);
}

unsafe impl Encode for PDFDocumentPermissions {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for PDFDocumentPermissions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentdidunlocknotification?language=objc)
    pub static PDFDocumentDidUnlockNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentdidbeginfindnotification?language=objc)
    pub static PDFDocumentDidBeginFindNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentdidendfindnotification?language=objc)
    pub static PDFDocumentDidEndFindNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentdidbeginpagefindnotification?language=objc)
    pub static PDFDocumentDidBeginPageFindNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentdidendpagefindnotification?language=objc)
    pub static PDFDocumentDidEndPageFindNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentdidfindmatchnotification?language=objc)
    pub static PDFDocumentDidFindMatchNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentdidbeginwritenotification?language=objc)
    pub static PDFDocumentDidBeginWriteNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentdidendwritenotification?language=objc)
    pub static PDFDocumentDidEndWriteNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentdidbeginpagewritenotification?language=objc)
    pub static PDFDocumentDidBeginPageWriteNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentdidendpagewritenotification?language=objc)
    pub static PDFDocumentDidEndPageWriteNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentfoundselectionkey?language=objc)
    pub static PDFDocumentFoundSelectionKey: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentpageindexkey?language=objc)
    pub static PDFDocumentPageIndexKey: &'static NSString;
}

/// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentattribute?language=objc)
// NS_TYPED_ENUM
pub type PDFDocumentAttribute = NSString;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumenttitleattribute?language=objc)
    pub static PDFDocumentTitleAttribute: &'static PDFDocumentAttribute;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentauthorattribute?language=objc)
    pub static PDFDocumentAuthorAttribute: &'static PDFDocumentAttribute;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentsubjectattribute?language=objc)
    pub static PDFDocumentSubjectAttribute: &'static PDFDocumentAttribute;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentcreatorattribute?language=objc)
    pub static PDFDocumentCreatorAttribute: &'static PDFDocumentAttribute;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentproducerattribute?language=objc)
    pub static PDFDocumentProducerAttribute: &'static PDFDocumentAttribute;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentcreationdateattribute?language=objc)
    pub static PDFDocumentCreationDateAttribute: &'static PDFDocumentAttribute;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentmodificationdateattribute?language=objc)
    pub static PDFDocumentModificationDateAttribute: &'static PDFDocumentAttribute;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentkeywordsattribute?language=objc)
    pub static PDFDocumentKeywordsAttribute: &'static PDFDocumentAttribute;
}

/// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentwriteoption?language=objc)
// NS_TYPED_ENUM
pub type PDFDocumentWriteOption = NSString;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentownerpasswordoption?language=objc)
    pub static PDFDocumentOwnerPasswordOption: &'static PDFDocumentWriteOption;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentuserpasswordoption?language=objc)
    pub static PDFDocumentUserPasswordOption: &'static PDFDocumentWriteOption;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentaccesspermissionsoption?language=objc)
    pub static PDFDocumentAccessPermissionsOption: &'static PDFDocumentWriteOption;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentburninannotationsoption?language=objc)
    pub static PDFDocumentBurnInAnnotationsOption: &'static PDFDocumentWriteOption;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentsavetextfromocroption?language=objc)
    pub static PDFDocumentSaveTextFromOCROption: &'static PDFDocumentWriteOption;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentsaveimagesasjpegoption?language=objc)
    pub static PDFDocumentSaveImagesAsJPEGOption: &'static PDFDocumentWriteOption;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentoptimizeimagesforscreenoption?language=objc)
    pub static PDFDocumentOptimizeImagesForScreenOption: &'static PDFDocumentWriteOption;
}

/// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfaccesspermissions?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PDFAccessPermissions(pub NSUInteger);
impl PDFAccessPermissions {
    #[doc(alias = "PDFAllowsLowQualityPrinting")]
    pub const AllowsLowQualityPrinting: Self = Self(1 << 0);
    #[doc(alias = "PDFAllowsHighQualityPrinting")]
    pub const AllowsHighQualityPrinting: Self = Self(1 << 1);
    #[doc(alias = "PDFAllowsDocumentChanges")]
    pub const AllowsDocumentChanges: Self = Self(1 << 2);
    #[doc(alias = "PDFAllowsDocumentAssembly")]
    pub const AllowsDocumentAssembly: Self = Self(1 << 3);
    #[doc(alias = "PDFAllowsContentCopying")]
    pub const AllowsContentCopying: Self = Self(1 << 4);
    #[doc(alias = "PDFAllowsContentAccessibility")]
    pub const AllowsContentAccessibility: Self = Self(1 << 5);
    #[doc(alias = "PDFAllowsCommenting")]
    pub const AllowsCommenting: Self = Self(1 << 6);
    #[doc(alias = "PDFAllowsFormFieldEntry")]
    pub const AllowsFormFieldEntry: Self = Self(1 << 7);
}

unsafe impl Encode for PDFAccessPermissions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for PDFAccessPermissions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocument?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct PDFDocument;
);

extern_conformance!(
    unsafe impl NSCopying for PDFDocument {}
);

unsafe impl CopyingHelper for PDFDocument {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for PDFDocument {}
);

impl PDFDocument {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(initWithURL:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Option<Retained<Self>>;

        #[unsafe(method(initWithData:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithData(this: Allocated<Self>, data: &NSData) -> Option<Retained<Self>>;

        #[unsafe(method(documentURL))]
        #[unsafe(method_family = none)]
        pub unsafe fn documentURL(&self) -> Option<Retained<NSURL>>;

        #[cfg(feature = "objc2-core-graphics")]
        #[unsafe(method(documentRef))]
        #[unsafe(method_family = none)]
        pub unsafe fn documentRef(&self) -> Option<Retained<CGPDFDocument>>;

        #[unsafe(method(documentAttributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn documentAttributes(&self) -> Option<Retained<NSDictionary>>;

        /// Setter for [`documentAttributes`][Self::documentAttributes].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `document_attributes` generic should be of the correct type.
        #[unsafe(method(setDocumentAttributes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDocumentAttributes(&self, document_attributes: Option<&NSDictionary>);

        #[unsafe(method(majorVersion))]
        #[unsafe(method_family = none)]
        pub unsafe fn majorVersion(&self) -> NSInteger;

        #[unsafe(method(minorVersion))]
        #[unsafe(method_family = none)]
        pub unsafe fn minorVersion(&self) -> NSInteger;

        #[unsafe(method(isEncrypted))]
        #[unsafe(method_family = none)]
        pub unsafe fn isEncrypted(&self) -> bool;

        #[unsafe(method(isLocked))]
        #[unsafe(method_family = none)]
        pub unsafe fn isLocked(&self) -> bool;

        #[unsafe(method(unlockWithPassword:))]
        #[unsafe(method_family = none)]
        pub unsafe fn unlockWithPassword(&self, password: &NSString) -> bool;

        #[unsafe(method(allowsPrinting))]
        #[unsafe(method_family = none)]
        pub unsafe fn allowsPrinting(&self) -> bool;

        #[unsafe(method(allowsCopying))]
        #[unsafe(method_family = none)]
        pub unsafe fn allowsCopying(&self) -> bool;

        #[unsafe(method(allowsDocumentChanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn allowsDocumentChanges(&self) -> bool;

        #[unsafe(method(allowsDocumentAssembly))]
        #[unsafe(method_family = none)]
        pub unsafe fn allowsDocumentAssembly(&self) -> bool;

        #[unsafe(method(allowsContentAccessibility))]
        #[unsafe(method_family = none)]
        pub unsafe fn allowsContentAccessibility(&self) -> bool;

        #[unsafe(method(allowsCommenting))]
        #[unsafe(method_family = none)]
        pub unsafe fn allowsCommenting(&self) -> bool;

        #[unsafe(method(allowsFormFieldEntry))]
        #[unsafe(method_family = none)]
        pub unsafe fn allowsFormFieldEntry(&self) -> bool;

        #[unsafe(method(accessPermissions))]
        #[unsafe(method_family = none)]
        pub unsafe fn accessPermissions(&self) -> PDFAccessPermissions;

        #[unsafe(method(permissionsStatus))]
        #[unsafe(method_family = none)]
        pub unsafe fn permissionsStatus(&self) -> PDFDocumentPermissions;

        #[unsafe(method(string))]
        #[unsafe(method_family = none)]
        pub unsafe fn string(&self) -> Option<Retained<NSString>>;

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn PDFDocumentDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn PDFDocumentDelegate>>,
        );

        #[unsafe(method(dataRepresentation))]
        #[unsafe(method_family = none)]
        pub unsafe fn dataRepresentation(&self) -> Option<Retained<NSData>>;

        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(dataRepresentationWithOptions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn dataRepresentationWithOptions(
            &self,
            options: &NSDictionary,
        ) -> Option<Retained<NSData>>;

        #[unsafe(method(writeToFile:))]
        #[unsafe(method_family = none)]
        pub unsafe fn writeToFile(&self, path: &NSString) -> bool;

        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(writeToFile:withOptions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn writeToFile_withOptions(
            &self,
            path: &NSString,
            options: Option<&NSDictionary<PDFDocumentWriteOption, AnyObject>>,
        ) -> bool;

        #[unsafe(method(writeToURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn writeToURL(&self, url: &NSURL) -> bool;

        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(writeToURL:withOptions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn writeToURL_withOptions(
            &self,
            url: &NSURL,
            options: Option<&NSDictionary<PDFDocumentWriteOption, AnyObject>>,
        ) -> bool;

        #[cfg(feature = "PDFOutline")]
        #[unsafe(method(outlineRoot))]
        #[unsafe(method_family = none)]
        pub unsafe fn outlineRoot(&self) -> Option<Retained<PDFOutline>>;

        #[cfg(feature = "PDFOutline")]
        /// Setter for [`outlineRoot`][Self::outlineRoot].
        #[unsafe(method(setOutlineRoot:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setOutlineRoot(&self, outline_root: Option<&PDFOutline>);

        #[cfg(all(feature = "PDFOutline", feature = "PDFSelection"))]
        #[unsafe(method(outlineItemForSelection:))]
        #[unsafe(method_family = none)]
        pub unsafe fn outlineItemForSelection(
            &self,
            selection: &PDFSelection,
        ) -> Option<Retained<PDFOutline>>;

        #[unsafe(method(pageCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn pageCount(&self) -> NSUInteger;

        #[cfg(feature = "PDFPage")]
        #[unsafe(method(pageAtIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn pageAtIndex(&self, index: NSUInteger) -> Option<Retained<PDFPage>>;

        #[cfg(feature = "PDFPage")]
        #[unsafe(method(indexForPage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn indexForPage(&self, page: &PDFPage) -> NSUInteger;

        #[cfg(feature = "PDFPage")]
        #[unsafe(method(insertPage:atIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertPage_atIndex(&self, page: &PDFPage, index: NSUInteger);

        #[unsafe(method(removePageAtIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removePageAtIndex(&self, index: NSUInteger);

        #[unsafe(method(exchangePageAtIndex:withPageAtIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn exchangePageAtIndex_withPageAtIndex(
            &self,
            index_a: NSUInteger,
            index_b: NSUInteger,
        );

        #[unsafe(method(pageClass))]
        #[unsafe(method_family = none)]
        pub unsafe fn pageClass(&self) -> &'static AnyClass;

        #[cfg(feature = "PDFSelection")]
        #[unsafe(method(findString:withOptions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn findString_withOptions(
            &self,
            string: &NSString,
            options: NSStringCompareOptions,
        ) -> Retained<NSArray<PDFSelection>>;

        #[unsafe(method(beginFindString:withOptions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn beginFindString_withOptions(
            &self,
            string: &NSString,
            options: NSStringCompareOptions,
        );

        #[unsafe(method(beginFindStrings:withOptions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn beginFindStrings_withOptions(
            &self,
            strings: &NSArray<NSString>,
            options: NSStringCompareOptions,
        );

        #[cfg(feature = "PDFSelection")]
        #[unsafe(method(findString:fromSelection:withOptions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn findString_fromSelection_withOptions(
            &self,
            string: &NSString,
            selection: Option<&PDFSelection>,
            options: NSStringCompareOptions,
        ) -> Option<Retained<PDFSelection>>;

        #[unsafe(method(isFinding))]
        #[unsafe(method_family = none)]
        pub unsafe fn isFinding(&self) -> bool;

        #[unsafe(method(cancelFindString))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancelFindString(&self);

        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(printOperationForPrintInfo:scalingMode:autoRotate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn printOperationForPrintInfo_scalingMode_autoRotate(
            &self,
            print_info: Option<&NSPrintInfo>,
            scale_mode: PDFPrintScalingMode,
            do_rotate: bool,
            mtm: MainThreadMarker,
        ) -> Option<Retained<NSPrintOperation>>;

        #[cfg(feature = "PDFSelection")]
        #[unsafe(method(selectionForEntireDocument))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectionForEntireDocument(&self) -> Option<Retained<PDFSelection>>;

        #[cfg(all(feature = "PDFPage", feature = "PDFSelection"))]
        #[unsafe(method(selectionFromPage:atPoint:toPage:atPoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectionFromPage_atPoint_toPage_atPoint(
            &self,
            start_page: &PDFPage,
            start_point: NSPoint,
            end_page: &PDFPage,
            end_point: NSPoint,
        ) -> Option<Retained<PDFSelection>>;

        #[cfg(all(feature = "PDFPage", feature = "PDFSelection"))]
        #[unsafe(method(selectionFromPage:atPoint:toPage:atPoint:withGranularity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectionFromPage_atPoint_toPage_atPoint_withGranularity(
            &self,
            start_page: &PDFPage,
            start_point: NSPoint,
            end_page: &PDFPage,
            end_point: NSPoint,
            granularity: PDFSelectionGranularity,
        ) -> Option<Retained<PDFSelection>>;

        #[cfg(all(feature = "PDFPage", feature = "PDFSelection"))]
        #[unsafe(method(selectionFromPage:atCharacterIndex:toPage:atCharacterIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectionFromPage_atCharacterIndex_toPage_atCharacterIndex(
            &self,
            start_page: &PDFPage,
            start_character: NSUInteger,
            end_page: &PDFPage,
            end_character: NSUInteger,
        ) -> Option<Retained<PDFSelection>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl PDFDocument {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdocumentdelegate?language=objc)
    pub unsafe trait PDFDocumentDelegate: NSObjectProtocol {
        #[optional]
        #[unsafe(method(documentDidUnlock:))]
        #[unsafe(method_family = none)]
        unsafe fn documentDidUnlock(&self, notification: &NSNotification);

        #[optional]
        #[unsafe(method(documentDidBeginDocumentFind:))]
        #[unsafe(method_family = none)]
        unsafe fn documentDidBeginDocumentFind(&self, notification: &NSNotification);

        #[optional]
        #[unsafe(method(documentDidEndDocumentFind:))]
        #[unsafe(method_family = none)]
        unsafe fn documentDidEndDocumentFind(&self, notification: &NSNotification);

        #[optional]
        #[unsafe(method(documentDidBeginPageFind:))]
        #[unsafe(method_family = none)]
        unsafe fn documentDidBeginPageFind(&self, notification: &NSNotification);

        #[optional]
        #[unsafe(method(documentDidEndPageFind:))]
        #[unsafe(method_family = none)]
        unsafe fn documentDidEndPageFind(&self, notification: &NSNotification);

        #[optional]
        #[unsafe(method(documentDidFindMatch:))]
        #[unsafe(method_family = none)]
        unsafe fn documentDidFindMatch(&self, notification: &NSNotification);

        #[cfg(feature = "PDFSelection")]
        #[optional]
        #[unsafe(method(didMatchString:))]
        #[unsafe(method_family = none)]
        unsafe fn didMatchString(&self, instance: &PDFSelection);

        #[optional]
        #[unsafe(method(classForPage))]
        #[unsafe(method_family = none)]
        unsafe fn classForPage(&self) -> &'static AnyClass;

        #[optional]
        #[unsafe(method(classForAnnotationType:))]
        #[unsafe(method_family = none)]
        unsafe fn classForAnnotationType(&self, annotation_type: &NSString) -> &'static AnyClass;

        /// # Safety
        ///
        /// `annotation_class` probably has further requirements.
        #[deprecated]
        #[optional]
        #[unsafe(method(classForAnnotationClass:))]
        #[unsafe(method_family = none)]
        unsafe fn classForAnnotationClass(&self, annotation_class: &AnyClass) -> &'static AnyClass;
    }
);