PDFKit bug: PDFDocument properties return wrong security permissions.

XCode 10.3, macOS 10.14
*I don't check it on iOS.

Bug details

We can get security permissions of PDF by following properties of PDFDocument instance. But It's not correct permissions on some cases.

developer.apple.com

  • If PDF has printing permission (both of high or low resolution are ok), allowsCopying is always YES regardless of the PDF has copying permission.
  • If PDF has copying permission, allowsPrinting is always YES regardless of the PDF has printing permission.

*It seems the preview of macOS use these permission values. So we can print a PDF if it has copying permission even there is no printing permission. And we can copy the contents of a PDF if it has printing permission even there is no copying permission.

Can we get correct permissions from PDFDocument instance?

We can use CGPDFDocumentAllowsCopying() and CGPDFDocumentsAllowPrinting() from PDFDocument.documentRef. These functions return correct PDF permissions.